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


C# IILGen.Do方法代码示例

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


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

示例1: Load

 public void Load(IILGen ilGenerator, Action<IILGen> pushReaderOrCtx)
 {
     ilGenerator
         .Do(pushReaderOrCtx)
         .Callvirt(() => default(IReaderCtx).ReadNativeObject());
     var type = HandledType();
     ilGenerator.Do(_service.TypeConvertorGenerator.GenerateConversion(typeof(object), type));
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:8,代码来源:ServiceObjectFieldHandler.cs

示例2: GenerateLoadEx

 public static void GenerateLoadEx(this ITypeDescriptor descriptor, IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx, Action<IILGen> pushDescriptor, Type asType, ITypeConvertorGenerator convertorGenerator)
 {
     if (descriptor.StoredInline)
     {
         if (descriptor.LoadNeedsHelpWithConversion && asType!=typeof(object))
         {
             var origType = descriptor.GetPreferedType();
             descriptor.GenerateLoad(ilGenerator, pushReader, pushCtx, pushDescriptor, origType);
             if (origType != asType)
             {
                 var conv = convertorGenerator.GenerateConversion(origType, asType);
                 if (conv == null)
                     throw new BTDBException("Don't know how to convert " + descriptor.Name + " from " +
                                             origType.ToSimpleName() + " to " + asType.ToSimpleName());
                 conv(ilGenerator);
             }
         }
         else
         {
             descriptor.GenerateLoad(ilGenerator, pushReader, pushCtx, pushDescriptor, asType);
         }
     }
     else
     {
         ilGenerator
             .Do(pushCtx)
             .Callvirt(() => default(ITypeBinaryDeserializerContext).LoadObject());
         if (asType != typeof(object))
             ilGenerator.Castclass(asType);
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:31,代码来源:TypeDescriptorExtensions.cs

示例3: Save

 public void Save(IILGen ilGenerator, Action<IILGen> pushWriterOrCtx, Action<IILGen> pushValue)
 {
     ilGenerator
         .Do(pushWriterOrCtx)
         .Do(pushValue)
         .Do(_service.TypeConvertorGenerator.GenerateConversion(HandledType(), typeof(object)))
         .Callvirt(() => default(IWriterCtx).WriteNativeObject(null));
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:8,代码来源:ServiceObjectFieldHandler.cs

示例4: FreeContent

 public bool FreeContent(IILGen ilGenerator, Action<IILGen> pushReaderOrCtx)
 {
     var tableInfo = ((ObjectDB) _objectDB).TablesInfo.FindByType(HandledType());
     //decides upon current version  (null for object types never stored in DB)
     var needsContent = tableInfo == null || tableInfo.GetFreeContent(tableInfo.ClientTypeVersion).Item1;
     ilGenerator
         .Do(pushReaderOrCtx)
         .Callvirt(() => default(IReaderCtx).FreeContentInNativeObject());
     return needsContent;
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:10,代码来源:DBObjectFieldHandler.cs

示例5: GenerateSkipEx

 public static void GenerateSkipEx(this ITypeDescriptor descriptor, IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx)
 {
     if (descriptor.StoredInline)
     {
         descriptor.GenerateSkip(ilGenerator, pushReader, pushCtx);
     }
     else
     {
         ilGenerator
             .Do(pushCtx)
             .Callvirt(() => default(ITypeBinaryDeserializerContext).SkipObject());
     }
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:13,代码来源:TypeDescriptorExtensions.cs

示例6: GenerateSaveEx

 public static void GenerateSaveEx(this ITypeDescriptor descriptor, IILGen ilGenerator, Action<IILGen> pushWriter, Action<IILGen> pushCtx, Action<IILGen> pushSubValue, Type subValueType)
 {
     if (descriptor.StoredInline)
     {
         descriptor.GenerateSave(ilGenerator, pushWriter, pushCtx, pushSubValue, subValueType);
     }
     else
     {
         ilGenerator
             .Do(pushCtx)
             .Do(pushSubValue)
             .Callvirt(() => default(ITypeBinarySerializerContext).StoreObject(null));
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:14,代码来源:TypeDescriptorExtensions.cs

示例7: GenerateLoadEx

 public static void GenerateLoadEx(this ITypeDescriptor descriptor, IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx, Action<IILGen> pushDescriptor, Type asType)
 {
     if (descriptor.StoredInline)
     {
         descriptor.GenerateLoad(ilGenerator, pushReader, pushCtx, pushDescriptor, asType);
     }
     else
     {
         ilGenerator
             .Do(pushCtx)
             .Callvirt(() => default(ITypeBinaryDeserializerContext).LoadObject());
         if (asType != typeof(object))
             ilGenerator.Castclass(asType);
     }
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:15,代码来源:TypeDescriptorExtensions.cs

示例8: Load

 public void Load(IILGen ilGenerator, Action<IILGen> pushReaderOrCtx)
 {
     var localCount = ilGenerator.DeclareLocal(typeof(uint));
     var localResultOfObject = ilGenerator.DeclareLocal(typeof(object));
     var localResult = ilGenerator.DeclareLocal(HandledType());
     var loadSkipped = ilGenerator.DefineLabel();
     var loadFinished = ilGenerator.DefineLabel();
     var finish = ilGenerator.DefineLabel();
     var next = ilGenerator.DefineLabel();
     object fake;
     ilGenerator
         .Do(pushReaderOrCtx)
         .Ldloca(localResultOfObject)
         .Callvirt(() => default(IReaderCtx).ReadObject(out fake))
         .Brfalse(loadSkipped)
         .Do(Extensions.PushReaderFromCtx(pushReaderOrCtx))
         .Callvirt(() => default(AbstractBufferedReader).ReadVUInt32())
         .Stloc(localCount)
         .Ldloc(localCount)
         .Newobj(typeof(List<>).MakeGenericType(_type.GetGenericArguments()[0]).GetConstructor(new[] { typeof(int) }))
         .Stloc(localResult)
         .Do(pushReaderOrCtx)
         .Ldloc(localResult)
         .Castclass(typeof(object))
         .Callvirt(() => default(IReaderCtx).RegisterObject(null))
         .Mark(next)
         .Ldloc(localCount)
         .Brfalse(loadFinished)
         .Ldloc(localCount)
         .LdcI4(1)
         .Sub()
         .ConvU4()
         .Stloc(localCount)
         .Ldloc(localResult)
         .GenerateLoad(_itemsHandler, _type.GetGenericArguments()[0], pushReaderOrCtx, _typeConvertorGenerator)
         .Callvirt(_type.GetInterface("ICollection`1").GetMethod("Add"))
         .Br(next)
         .Mark(loadFinished)
         .Do(pushReaderOrCtx)
         .Callvirt(() => default(IReaderCtx).ReadObjectDone())
         .Br(finish)
         .Mark(loadSkipped)
         .Ldloc(localResultOfObject)
         .Isinst(_type)
         .Stloc(localResult)
         .Mark(finish)
         .Ldloc(localResult);
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:48,代码来源:ListFieldHandler.cs

示例9: Skip

 public void Skip(IILGen ilGenerator, Action<IILGen> pushReaderOrCtx)
 {
     // TODO register dict id for deletion
     ilGenerator
         .Do(Extensions.PushReaderFromCtx(pushReaderOrCtx))
         .Callvirt(() => default(AbstractBufferedReader).SkipVUInt64());
 }
开发者ID:yonglehou,项目名称:BTDB,代码行数:7,代码来源:ODBDictionaryFieldHandler.cs

示例10: 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

示例11: GenerateTypeIterator

 public void GenerateTypeIterator(IILGen ilGenerator, Action<IILGen> pushObj, Action<IILGen> pushCtx)
 {
     var finish = ilGenerator.DefineLabel();
     var next = ilGenerator.DefineLabel();
     var keyType = _owner._typeSerializers.LoadAsType(_owner._keyDescriptor);
     var valueType = _owner._typeSerializers.LoadAsType(_owner._valueDescriptor);
     var typeAsIDictionary = typeof(IDictionary<,>).MakeGenericType(keyType, valueType);
     var typeAsICollection = typeAsIDictionary.GetInterface("ICollection`1");
     var typeAsIEnumerable = typeAsIDictionary.GetInterface("IEnumerable`1");
     var getEnumeratorMethod = typeAsIEnumerable.GetMethod("GetEnumerator");
     var typeAsIEnumerator = getEnumeratorMethod.ReturnType;
     var typeKeyValuePair = typeAsICollection.GetGenericArguments()[0];
     var localEnumerator = ilGenerator.DeclareLocal(typeAsIEnumerator);
     var localPair = ilGenerator.DeclareLocal(typeKeyValuePair);
     ilGenerator
         .Do(pushObj)
         .Castclass(typeAsIDictionary)
         .Callvirt(getEnumeratorMethod)
         .Stloc(localEnumerator)
         .Try()
         .Mark(next)
         .Ldloc(localEnumerator)
         .Callvirt(() => default(IEnumerator).MoveNext())
         .Brfalse(finish)
         .Ldloc(localEnumerator)
         .Callvirt(typeAsIEnumerator.GetProperty("Current").GetGetMethod())
         .Stloc(localPair);
     if (!_owner._keyDescriptor.Sealed)
     {
         ilGenerator
             .Do(pushCtx)
             .Ldloca(localPair)
             .Call(typeKeyValuePair.GetProperty("Key").GetGetMethod())
             .Callvirt(() => default(IDescriptorSerializerLiteContext).StoreNewDescriptors(null));
     }
     if (!_owner._valueDescriptor.Sealed)
     {
         ilGenerator
             .Do(pushCtx)
             .Ldloca(localPair)
             .Call(typeKeyValuePair.GetProperty("Value").GetGetMethod())
             .Callvirt(() => default(IDescriptorSerializerLiteContext).StoreNewDescriptors(null));
     }
     ilGenerator
         .Br(next)
         .Mark(finish)
         .Finally()
         .Ldloc(localEnumerator)
         .Callvirt(() => default(IDisposable).Dispose())
         .EndTry();
 }
开发者ID:yonglehou,项目名称:BTDB,代码行数:51,代码来源:DictionaryTypeDescriptor.cs

示例12: GenerateSkip

 public void GenerateSkip(IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx)
 {
     var localCount = ilGenerator.DeclareLocal(typeof(uint));
     var skipFinished = ilGenerator.DefineLabel();
     var next = ilGenerator.DefineLabel();
     ilGenerator
         .Do(pushReader)
         .Callvirt(() => default(AbstractBufferedReader).ReadVUInt32())
         .Stloc(localCount)
         .Ldloc(localCount)
         .Brfalse(skipFinished)
         .Mark(next)
         .Ldloc(localCount)
         .LdcI4(1)
         .Sub()
         .Stloc(localCount)
         .Ldloc(localCount)
         .Brfalse(skipFinished);
     _keyDescriptor.GenerateSkipEx(ilGenerator, pushReader, pushCtx);
     _valueDescriptor.GenerateSkipEx(ilGenerator, pushReader, pushCtx);
     ilGenerator
         .Br(next)
         .Mark(skipFinished);
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:24,代码来源:DictionaryTypeDescriptor.cs

示例13: GenerateLoad

 public void GenerateLoad(IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx, Action<IILGen> pushDescriptor, Type targetType)
 {
     var localCount = ilGenerator.DeclareLocal(typeof(int));
     var targetIDictionary = targetType.GetInterface("IDictionary`2") ?? targetType;
     var targetTypeArguments = targetIDictionary.GetGenericArguments();
     var keyType = _typeSerializers.LoadAsType(_keyDescriptor, targetTypeArguments[0]);
     var valueType = _typeSerializers.LoadAsType(_valueDescriptor, targetTypeArguments[1]);
     var dictionaryType = typeof(DictionaryWithDescriptor<,>).MakeGenericType(keyType, valueType);
     if (!targetType.IsAssignableFrom(dictionaryType)) throw new InvalidOperationException();
     var localDict = ilGenerator.DeclareLocal(dictionaryType);
     var loadFinished = ilGenerator.DefineLabel();
     var next = ilGenerator.DefineLabel();
     ilGenerator
         .Do(pushReader)
         .Callvirt(() => default(AbstractBufferedReader).ReadVUInt32())
         .ConvI4()
         .Dup()
         .LdcI4(1)
         .Sub()
         .Stloc(localCount)
         .Brfalse(loadFinished)
         .Ldloc(localCount)
         .Do(pushDescriptor)
         .Newobj(dictionaryType.GetConstructor(new[] { typeof(int), typeof(ITypeDescriptor) }))
         .Stloc(localDict)
         .Mark(next)
         .Ldloc(localCount)
         .Brfalse(loadFinished)
         .Ldloc(localCount)
         .LdcI4(1)
         .Sub()
         .Stloc(localCount)
         .Ldloc(localDict);
     _keyDescriptor.GenerateLoadEx(ilGenerator, pushReader, pushCtx, il => il.Do(pushDescriptor).LdcI4(0).Callvirt(() => default(ITypeDescriptor).NestedType(0)), keyType, _convertorGenerator);
     _valueDescriptor.GenerateLoadEx(ilGenerator, pushReader, pushCtx, il => il.Do(pushDescriptor).LdcI4(1).Callvirt(() => default(ITypeDescriptor).NestedType(0)), valueType, _convertorGenerator);
     ilGenerator
         .Callvirt(dictionaryType.GetMethod("Add"))
         .Br(next)
         .Mark(loadFinished)
         .Ldloc(localDict)
         .Castclass(targetType);
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:42,代码来源:DictionaryTypeDescriptor.cs

示例14: Skip

 public void Skip(IILGen ilGenerator, Action<IILGen> pushReaderOrCtx)
 {
     ilGenerator
         .Do(pushReaderOrCtx)
         .Callvirt(() => default(IReaderCtx).SkipNativeObject());
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:6,代码来源:DBObjectFieldHandler.cs

示例15: GenerateTypeIterator

 public void GenerateTypeIterator(IILGen ilGenerator, Action<IILGen> pushObj, Action<IILGen> pushCtx)
 {
     var finish = ilGenerator.DefineLabel();
     var next = ilGenerator.DefineLabel();
     var itemType = _listTypeDescriptor._typeSerializers.LoadAsType(_listTypeDescriptor._itemDescriptor);
     var localList = ilGenerator.DeclareLocal(typeof(IList<>).MakeGenericType(itemType));
     var localIndex = ilGenerator.DeclareLocal(typeof(int));
     var localCount = ilGenerator.DeclareLocal(typeof(int));
     ilGenerator
         .Do(pushObj)
         .Castclass(localList.LocalType)
         .Dup()
         .Stloc(localList)
         .Callvirt(localList.LocalType.GetInterface("ICollection`1").GetProperty("Count").GetGetMethod())
         .Stloc(localCount)
         .LdcI4(0)
         .Stloc(localIndex)
         .Mark(next)
         .Ldloc(localIndex)
         .Ldloc(localCount)
         .BgeUn(finish)
         .Do(pushCtx)
         .Ldloc(localList)
         .Ldloc(localIndex)
         .Callvirt(localList.LocalType.GetMethod("get_Item"))
         .Callvirt(() => default(IDescriptorSerializerLiteContext).StoreNewDescriptors(null))
         .Ldloc(localIndex)
         .LdcI4(1)
         .Add()
         .Stloc(localIndex)
         .Br(next)
         .Mark(finish);
 }
开发者ID:yonglehou,项目名称:BTDB,代码行数:33,代码来源:ListTypeDescriptor.cs


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