Example #1
0
        private ILogEvent AppendEnumInternal <T>(T value)
        {
            if (!PrepareAppend(sizeof(ArgumentType) + sizeof(EnumArg)))
            {
                return(this);
            }

            AppendArgumentType(ArgumentType.Enum);
            *(EnumArg *)_dataPointer = new EnumArg(TypeUtil <T> .TypeHandle, EnumCache.ToUInt64(value));
            _dataPointer            += sizeof(EnumArg);
            return(this);
        }
Example #2
0
        private void AppendNullableEnumInternal <T>(T value) // T = Nullable<SomeEnum>
        {
            if (!PrepareAppend(sizeof(ArgumentType) + sizeof(EnumArg)))
            {
                return;
            }

            var enumValue = EnumCache.ToUInt64Nullable(value);

            if (enumValue == null)
            {
                AppendArgumentType(ArgumentType.Null);
                return;
            }

            AppendArgumentType(ArgumentType.Enum);
            *(EnumArg *)_dataPointer = new EnumArg(TypeUtilSlow <T> .UnderlyingTypeHandle, enumValue.GetValueOrDefault());
            _dataPointer            += sizeof(EnumArg);
        }