本文整理汇总了C#中IILGen.Castclass方法的典型用法代码示例。如果您正苦于以下问题:C# IILGen.Castclass方法的具体用法?C# IILGen.Castclass怎么用?C# IILGen.Castclass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IILGen
的用法示例。
在下文中一共展示了IILGen.Castclass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: GenerateLoad
public void GenerateLoad(IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx, Action<IILGen> pushDescriptor, Type targetType)
{
pushReader(ilGenerator);
ilGenerator.Call(() => default(AbstractBufferedReader).ReadByteArray());
if (targetType == typeof (ByteBuffer))
{
ilGenerator.Call(() => ByteBuffer.NewAsync(null));
return;
}
if (targetType != typeof (object))
{
if (targetType!=typeof(byte[]))
throw new ArgumentOutOfRangeException(nameof(targetType));
return;
}
ilGenerator.Castclass(typeof(object));
}
示例4: 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);
}
示例5: GenerateLoad
public void GenerateLoad(IILGen ilGenerator, Action<IILGen> pushReader, Action<IILGen> pushCtx, Action<IILGen> pushDescriptor, Type targetType)
{
pushReader(ilGenerator);
ilGenerator.Call(_loader);
if (targetType != typeof(object))
{
if (targetType != GetPreferedType())
throw new ArgumentOutOfRangeException(nameof(targetType));
return;
}
if (GetPreferedType().IsValueType)
{
ilGenerator.Box(GetPreferedType());
}
else
{
ilGenerator.Castclass(typeof(object));
}
}