Skip to content

Commit

Permalink
Removed 1 type from hex list and simplified the check so we only main…
Browse files Browse the repository at this point in the history
…tain what needs to be converted
  • Loading branch information
jschick04 authored and bill-long committed May 29, 2024
1 parent 4913784 commit d5d9418
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/EventLogExpert.Eventing/EventResolvers/EventResolverBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,13 @@ public partial class EventResolverBase
/// The mappings from the outType attribute in the EventModel XML template
/// to determine if it should be displayed as Hex.
/// </summary>
private static readonly Dictionary<string, bool> XmlHexMappings = new()
{
{ "win:HexInt32", true },
{ "win:HexInt64", true },
{ "win:Pointer", true },
{ "win:SID", false },
{ "win:UnicodeString", false },
{ "win:Win32Error", true },
{ "xs:dateTime", false },
{ "xs:GUID", false },
{ "xs:string", false },
{ "xs:unsignedByte", true },
{ "xs:unsignedInt", false },
{ "xs:unsignedLong", false }
};
private static readonly List<string> DisplayAsHexTypes =
[
"win:HexInt32",
"win:HexInt64",
"win:Pointer",
"win:Win32Error",
];

protected readonly Action<string, LogLevel> _tracer;

Expand Down Expand Up @@ -328,9 +320,9 @@ private static List<string> GetFormattedProperties(string? template, IList<Event
continue;
}

if (XmlHexMappings.TryGetValue(outType, out bool isHex))
if (DisplayAsHexTypes.Contains(outType, StringComparer.OrdinalIgnoreCase))
{
providers.Add(isHex ? $"0x{properties[i].Value:X}" : $"{properties[i].Value}");
providers.Add($"0x{properties[i].Value:X}");
}
else if (string.Equals(outType, "win:HResult", StringComparison.OrdinalIgnoreCase) &&
properties[i].Value is int hResult)
Expand Down

0 comments on commit d5d9418

Please sign in to comment.