本文整理汇总了C#中ITypeDescriptor.BuildNewDescriptorGenerator方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDescriptor.BuildNewDescriptorGenerator方法的具体用法?C# ITypeDescriptor.BuildNewDescriptorGenerator怎么用?C# ITypeDescriptor.BuildNewDescriptorGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDescriptor
的用法示例。
在下文中一共展示了ITypeDescriptor.BuildNewDescriptorGenerator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildNestedObjGatherer
Action<object, IDescriptorSerializerLiteContext> BuildNestedObjGatherer(ITypeDescriptor descriptor, Type type)
{
Action<object, IDescriptorSerializerLiteContext> res;
if (type != null)
{
if (_gathererCache.TryGetValue(type, out res))
return res;
}
var gen = descriptor.BuildNewDescriptorGenerator();
if (gen == null)
{
res = (obj, ctx) => { };
}
else
{
var method = ILBuilder.Instance.NewMethod<Action<object, IDescriptorSerializerLiteContext>>("GatherAllObjectsForTypeExtraction_" + descriptor.Name);
var il = method.Generator;
gen.GenerateTypeIterator(il, ilgen => ilgen.Ldarg(0), ilgen => ilgen.Ldarg(1), type);
il.Ret();
res = method.Create();
}
if (type != null) _gathererCache[type] = res;
return res;
}
示例2: NewDescriptorSaverFactory
Action<object, IDescriptorSerializerLiteContext> NewDescriptorSaverFactory(ITypeDescriptor descriptor)
{
var gen = descriptor.BuildNewDescriptorGenerator();
if (gen == null)
{
return null;
}
var method = ILBuilder.Instance.NewMethod<Action<object, IDescriptorSerializerLiteContext>>("GatherAllObjectsForTypeExtraction_" + descriptor.Name);
var il = method.Generator;
gen.GenerateTypeIterator(il, ilgen => ilgen.Ldarg(0), ilgen => ilgen.Ldarg(1), null);
il.Ret();
return method.Create();
}