static object FormatValue()

in Source/Tx.Windows/EtwTdh/EtwTdhEventInfo.cs [328:361]


        static object FormatValue(EtwPropertyInfo propertyInfo, object value)
        {
            if (propertyInfo.ValueMap != null)
            {
                uint key = Convert.ToUInt32(value);
                if (!propertyInfo.ValueMap.TryGetValue(key, out string name))
                {
                    name = value.ToString();
                }

                return name;
            }

            switch (propertyInfo.OutType)
            {
                case TdhOutType.SocketAddress:
                    return FormatAsIpAddress(value);

                case TdhOutType.HexInt8:
                    return "0x" + ((byte)value).ToString("X");

                case TdhOutType.HexInt16:
                    return "0x" + ((ushort)value).ToString("X");

                case TdhOutType.HexInt32:
                    return "0x" + ((uint)value).ToString("X");

                case TdhOutType.HexInt64:
                    return "0x" + ((ulong)value).ToString("X");

                default:
                    return value;
            }
        }