diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs index ae6088849..daa6d9736 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs @@ -40,33 +40,33 @@ namespace System.Diagnostics.Tracing public struct Scalar { [FieldOffset(0)] - public Boolean AsBoolean; + public bool AsBoolean; [FieldOffset(0)] - public Byte AsByte; + public byte AsByte; [FieldOffset(0)] - public SByte AsSByte; + public sbyte AsSByte; [FieldOffset(0)] - public Char AsChar; + public char AsChar; [FieldOffset(0)] - public Int16 AsInt16; + public short AsInt16; [FieldOffset(0)] - public UInt16 AsUInt16; + public ushort AsUInt16; [FieldOffset(0)] - public Int32 AsInt32; + public int AsInt32; [FieldOffset(0)] - public UInt32 AsUInt32; + public uint AsUInt32; [FieldOffset(0)] - public Int64 AsInt64; + public long AsInt64; [FieldOffset(0)] - public UInt64 AsUInt64; + public ulong AsUInt64; [FieldOffset(0)] public IntPtr AsIntPtr; [FieldOffset(0)] public UIntPtr AsUIntPtr; [FieldOffset(0)] - public Single AsSingle; + public float AsSingle; [FieldOffset(0)] - public Double AsDouble; + public double AsDouble; [FieldOffset(0)] public Guid AsGuid; [FieldOffset(0)] @@ -76,7 +76,7 @@ namespace System.Diagnostics.Tracing [FieldOffset(0)] public TimeSpan AsTimeSpan; [FieldOffset(0)] - public Decimal AsDecimal; + public decimal AsDecimal; } // Anything not covered by the Scalar union gets stored in this reference. @@ -87,7 +87,7 @@ namespace System.Diagnostics.Tracing private PropertyValue(object value) { _reference = value; - _scalar = default(Scalar); + _scalar = default; _scalarLength = 0; } @@ -98,47 +98,47 @@ namespace System.Diagnostics.Tracing _scalarLength = scalarLength; } - private PropertyValue(Boolean value) : this(new Scalar() { AsBoolean = value }, sizeof(Boolean)) { } - private PropertyValue(Byte value) : this(new Scalar() { AsByte = value }, sizeof(Byte)) { } - private PropertyValue(SByte value) : this(new Scalar() { AsSByte = value }, sizeof(SByte)) { } - private PropertyValue(Char value) : this(new Scalar() { AsChar = value }, sizeof(Char)) { } - private PropertyValue(Int16 value) : this(new Scalar() { AsInt16 = value }, sizeof(Int16)) { } - private PropertyValue(UInt16 value) : this(new Scalar() { AsUInt16 = value }, sizeof(UInt16)) { } - private PropertyValue(Int32 value) : this(new Scalar() { AsInt32 = value }, sizeof(Int32)) { } - private PropertyValue(UInt32 value) : this(new Scalar() { AsUInt32 = value }, sizeof(UInt32)) { } - private PropertyValue(Int64 value) : this(new Scalar() { AsInt64 = value }, sizeof(Int64)) { } - private PropertyValue(UInt64 value) : this(new Scalar() { AsUInt64 = value }, sizeof(UInt64)) { } + private PropertyValue(bool value) : this(new Scalar() { AsBoolean = value }, sizeof(bool)) { } + private PropertyValue(byte value) : this(new Scalar() { AsByte = value }, sizeof(byte)) { } + private PropertyValue(sbyte value) : this(new Scalar() { AsSByte = value }, sizeof(sbyte)) { } + private PropertyValue(char value) : this(new Scalar() { AsChar = value }, sizeof(char)) { } + private PropertyValue(short value) : this(new Scalar() { AsInt16 = value }, sizeof(short)) { } + private PropertyValue(ushort value) : this(new Scalar() { AsUInt16 = value }, sizeof(ushort)) { } + private PropertyValue(int value) : this(new Scalar() { AsInt32 = value }, sizeof(int)) { } + private PropertyValue(uint value) : this(new Scalar() { AsUInt32 = value }, sizeof(uint)) { } + private PropertyValue(long value) : this(new Scalar() { AsInt64 = value }, sizeof(long)) { } + private PropertyValue(ulong value) : this(new Scalar() { AsUInt64 = value }, sizeof(ulong)) { } private PropertyValue(IntPtr value) : this(new Scalar() { AsIntPtr = value }, sizeof(IntPtr)) { } private PropertyValue(UIntPtr value) : this(new Scalar() { AsUIntPtr = value }, sizeof(UIntPtr)) { } - private PropertyValue(Single value) : this(new Scalar() { AsSingle = value }, sizeof(Single)) { } - private PropertyValue(Double value) : this(new Scalar() { AsDouble = value }, sizeof(Double)) { } + private PropertyValue(float value) : this(new Scalar() { AsSingle = value }, sizeof(float)) { } + private PropertyValue(double value) : this(new Scalar() { AsDouble = value }, sizeof(double)) { } private PropertyValue(Guid value) : this(new Scalar() { AsGuid = value }, sizeof(Guid)) { } private PropertyValue(DateTime value) : this(new Scalar() { AsDateTime = value }, sizeof(DateTime)) { } private PropertyValue(DateTimeOffset value) : this(new Scalar() { AsDateTimeOffset = value }, sizeof(DateTimeOffset)) { } private PropertyValue(TimeSpan value) : this(new Scalar() { AsTimeSpan = value }, sizeof(TimeSpan)) { } - private PropertyValue(Decimal value) : this(new Scalar() { AsDecimal = value }, sizeof(Decimal)) { } + private PropertyValue(decimal value) : this(new Scalar() { AsDecimal = value }, sizeof(decimal)) { } public static Func<object, PropertyValue> GetFactory(Type type) { - if (type == typeof(Boolean)) return value => new PropertyValue((Boolean)value); - if (type == typeof(Byte)) return value => new PropertyValue((Byte)value); - if (type == typeof(SByte)) return value => new PropertyValue((SByte)value); - if (type == typeof(Char)) return value => new PropertyValue((Char)value); - if (type == typeof(Int16)) return value => new PropertyValue((Int16)value); - if (type == typeof(UInt16)) return value => new PropertyValue((UInt16)value); - if (type == typeof(Int32)) return value => new PropertyValue((Int32)value); - if (type == typeof(UInt32)) return value => new PropertyValue((UInt32)value); - if (type == typeof(Int64)) return value => new PropertyValue((Int64)value); - if (type == typeof(UInt64)) return value => new PropertyValue((UInt64)value); + if (type == typeof(bool)) return value => new PropertyValue((bool)value); + if (type == typeof(byte)) return value => new PropertyValue((byte)value); + if (type == typeof(sbyte)) return value => new PropertyValue((sbyte)value); + if (type == typeof(char)) return value => new PropertyValue((char)value); + if (type == typeof(short)) return value => new PropertyValue((short)value); + if (type == typeof(ushort)) return value => new PropertyValue((ushort)value); + if (type == typeof(int)) return value => new PropertyValue((int)value); + if (type == typeof(uint)) return value => new PropertyValue((uint)value); + if (type == typeof(long)) return value => new PropertyValue((long)value); + if (type == typeof(ulong)) return value => new PropertyValue((ulong)value); if (type == typeof(IntPtr)) return value => new PropertyValue((IntPtr)value); if (type == typeof(UIntPtr)) return value => new PropertyValue((UIntPtr)value); - if (type == typeof(Single)) return value => new PropertyValue((Single)value); - if (type == typeof(Double)) return value => new PropertyValue((Double)value); + if (type == typeof(float)) return value => new PropertyValue((float)value); + if (type == typeof(double)) return value => new PropertyValue((double)value); if (type == typeof(Guid)) return value => new PropertyValue((Guid)value); if (type == typeof(DateTime)) return value => new PropertyValue((DateTime)value); if (type == typeof(DateTimeOffset)) return value => new PropertyValue((DateTimeOffset)value); if (type == typeof(TimeSpan)) return value => new PropertyValue((TimeSpan)value); - if (type == typeof(Decimal)) return value => new PropertyValue((Decimal)value); + if (type == typeof(decimal)) return value => new PropertyValue((decimal)value); return value => new PropertyValue(value); } @@ -249,25 +249,25 @@ namespace System.Diagnostics.Tracing if (type.GetTypeInfo().IsEnum) type = Enum.GetUnderlyingType(type); - if (type == typeof(Boolean)) { var f = (Func<TContainer, Boolean>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Byte)) { var f = (Func<TContainer, Byte>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(SByte)) { var f = (Func<TContainer, SByte>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Char)) { var f = (Func<TContainer, Char>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Int16)) { var f = (Func<TContainer, Int16>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(UInt16)) { var f = (Func<TContainer, UInt16>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Int32)) { var f = (Func<TContainer, Int32>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(UInt32)) { var f = (Func<TContainer, UInt32>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Int64)) { var f = (Func<TContainer, Int64>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(UInt64)) { var f = (Func<TContainer, UInt64>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(bool)) { var f = (Func<TContainer, bool>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(byte)) { var f = (Func<TContainer, byte>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(sbyte)) { var f = (Func<TContainer, sbyte>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(char)) { var f = (Func<TContainer, char>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(short)) { var f = (Func<TContainer, short>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(ushort)) { var f = (Func<TContainer, ushort>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(int)) { var f = (Func<TContainer, int>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(uint)) { var f = (Func<TContainer, uint>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(long)) { var f = (Func<TContainer, long>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(ulong)) { var f = (Func<TContainer, ulong>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(IntPtr)) { var f = (Func<TContainer, IntPtr>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(UIntPtr)) { var f = (Func<TContainer, UIntPtr>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Single)) { var f = (Func<TContainer, Single>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Double)) { var f = (Func<TContainer, Double>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(float)) { var f = (Func<TContainer, float>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(double)) { var f = (Func<TContainer, double>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(Guid)) { var f = (Func<TContainer, Guid>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(DateTime)) { var f = (Func<TContainer, DateTime>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(DateTimeOffset)) { var f = (Func<TContainer, DateTimeOffset>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(TimeSpan)) { var f = (Func<TContainer, TimeSpan>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Decimal)) { var f = (Func<TContainer, Decimal>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(decimal)) { var f = (Func<TContainer, decimal>)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } return container => new PropertyValue(property.GetValue(container.ReferenceValue)); } |