当前位置: 首页>>代码示例>>C#>>正文


C# IILGen.Newobj方法代码示例

本文整理汇总了C#中IILGen.Newobj方法的典型用法代码示例。如果您正苦于以下问题:C# IILGen.Newobj方法的具体用法?C# IILGen.Newobj怎么用?C# IILGen.Newobj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IILGen的用法示例。


在下文中一共展示了IILGen.Newobj方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateLoad

 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);
 }
开发者ID:klesta490,项目名称:BTDB,代码行数:30,代码来源:EnumTypeDescriptor.cs

示例2: Init

 public void Init(IILGen ilGenerator, Action<IILGen> pushReaderCtx)
 {
     ilGenerator.Newobj(typeof(DBIndirect<>).MakeGenericType(_type).GetConstructor(Type.EmptyTypes));
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:4,代码来源:DBObjectFieldHandler.cs

示例3: GenerateLoad

 public void GenerateLoad(IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx, Action<IILGen> pushDescriptor, Type targetType)
 {
     if (targetType == typeof(object))
     {
         var resultLoc = ilGenerator.DeclareLocal(typeof(DynamicObject), "result");
         var labelNoCtx = ilGenerator.DefineLabel();
         ilGenerator
             .Do(pushDescriptor)
             .Castclass(typeof(ObjectTypeDescriptor))
             .Newobj(typeof(DynamicObject).GetConstructor(new[] { typeof(ObjectTypeDescriptor) }))
             .Stloc(resultLoc)
             .Do(pushCtx)
             .BrfalseS(labelNoCtx)
             .Do(pushCtx)
             .Ldloc(resultLoc)
             .Callvirt(() => default(ITypeBinaryDeserializerContext).AddBackRef(null))
             .Mark(labelNoCtx);
         var idx = 0;
         foreach (var pair in _fields)
         {
             var idxForCapture = idx;
             ilGenerator.Ldloc(resultLoc);
             ilGenerator.LdcI4(idx);
             pair.Value.GenerateLoadEx(ilGenerator, pushReader, pushCtx,
                 il =>
                     il.Do(pushDescriptor)
                         .LdcI4(idxForCapture)
                         .Callvirt(() => default(ITypeDescriptor).NestedType(0)), typeof(object), _typeSerializers.ConvertorGenerator);
             ilGenerator.Callvirt(() => default(DynamicObject).SetFieldByIdxFast(0, null));
             idx++;
         }
         ilGenerator
             .Ldloc(resultLoc)
             .Castclass(typeof(object));
     }
     else
     {
         var resultLoc = ilGenerator.DeclareLocal(targetType, "result");
         var labelNoCtx = ilGenerator.DefineLabel();
         ilGenerator
             .Newobj(targetType.GetConstructor(Type.EmptyTypes))
             .Stloc(resultLoc)
             .Do(pushCtx)
             .BrfalseS(labelNoCtx)
             .Do(pushCtx)
             .Ldloc(resultLoc)
             .Callvirt(() => default(ITypeBinaryDeserializerContext).AddBackRef(null))
             .Mark(labelNoCtx);
         var props = targetType.GetProperties();
         for (var idx = 0; idx < _fields.Count; idx++)
         {
             var idxForCapture = idx;
             var pair = _fields[idx];
             var prop = props.FirstOrDefault(p => GetPersitentName(p) == pair.Key);
             if (prop == null || !_typeSerializers.IsSafeToLoad(prop.PropertyType))
             {
                 pair.Value.GenerateSkipEx(ilGenerator, pushReader, pushCtx);
                 continue;
             }
             ilGenerator.Ldloc(resultLoc);
             pair.Value.GenerateLoadEx(ilGenerator, pushReader, pushCtx,
                                     il => il.Do(pushDescriptor).LdcI4(idxForCapture).Callvirt(() => default(ITypeDescriptor).NestedType(0)),
                                     prop.PropertyType, _typeSerializers.ConvertorGenerator);
             ilGenerator.Callvirt(prop.GetSetMethod());
         }
         ilGenerator.Ldloc(resultLoc);
     }
 }
开发者ID:klesta490,项目名称:BTDB,代码行数:68,代码来源:ObjectTypeDescriptor.cs


注:本文中的IILGen.Newobj方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。