本文整理汇总了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);
}
示例2: Init
public void Init(IILGen ilGenerator, Action<IILGen> pushReaderCtx)
{
ilGenerator.Newobj(typeof(DBIndirect<>).MakeGenericType(_type).GetConstructor(Type.EmptyTypes));
}
示例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);
}
}