本文整理汇总了C#中System.Reflection.Emit.CodeGenerator.StoreMember方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.StoreMember方法的具体用法?C# CodeGenerator.StoreMember怎么用?C# CodeGenerator.StoreMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.StoreMember方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoGetStaticFieldSetDelegate
/// <summary>
/// Do Get Static Field Set Delegate
/// </summary>
/// <param name="targetModule"></param>
/// <param name="fieldInfo"></param>
/// <returns></returns>
protected static StaticDynamicMethodProxyHandler DoGetStaticFieldSetDelegate(
Module targetModule,
FieldInfo fieldInfo
)
{
Check.Require(targetModule, "targetModule");
Check.Require(fieldInfo, "fieldInfo");
Check.Require(fieldInfo.IsStatic, "fieldInfo MUST be static here.");
CodeGenerator gen = new CodeGenerator(targetModule);
gen.BeginMethod("dm" + Guid.NewGuid().ToString("N"), typeof(StaticDynamicMethodProxyHandler));
gen.Ldarg(0);
gen.Ldc(0);
gen.Ldelem(typeof(object));
if (fieldInfo.FieldType.IsValueType)
gen.UnboxAny(fieldInfo.FieldType);
gen.StoreMember(fieldInfo);
gen.Load(null);
return (StaticDynamicMethodProxyHandler)gen.EndMethod();
}
示例2: SetMemberValue
public void SetMemberValue(CodeGenerator generator, ArgBuilder targetObject, string memberName, LocalBuilder memberValue)
{
MemberInfo memberInfo = ConvertorGeneratorHelper.GetMemberInfo(targetObject.ArgType, memberName);
if (memberInfo != null)
{
generator.Ldarg(targetObject);
generator.Ldloc(memberValue);
generator.StoreMember(memberInfo);
}
}