BTDB.EventStoreLayer.EnumTypeDescriptor.GenerateLoad C# (CSharp) Method

GenerateLoad() public method

public GenerateLoad ( IILGen ilGenerator, Action pushReader, Action pushCtx, Action pushDescriptor, Type targetType ) : void
ilGenerator IILGen
pushReader Action
pushCtx Action
pushDescriptor Action
targetType System.Type
return void
        public void GenerateLoad(IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx, Action<IILGen> pushDescriptor, Type targetType)
        {
            pushReader(ilGenerator);
            Type typeRead;
            if (_signed)
            {
                ilGenerator.Call(() => default(AbstractBufferedReader).ReadVInt64());
                typeRead = typeof(long);
            }
            else
            {
                ilGenerator.Call(() => default(AbstractBufferedReader).ReadVUInt64());
                typeRead = typeof(ulong);
            }
            if (targetType == typeof(object))
            {
                ilGenerator.Do(pushDescriptor);
                if (_signed)
                {
                    ilGenerator.Newobj(() => new DynamicEnum(0L, null));
                }
                else
                {
                    ilGenerator.Newobj(() => new DynamicEnum(0UL, null));
                }
                ilGenerator.Castclass(typeof(object));
                return;
            }
            new DefaultTypeConvertorGenerator().GenerateConversion(typeRead, targetType.GetEnumUnderlyingType())(ilGenerator);
        }