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


C# PropertyBuilder.SetGetMethod方法代码示例

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


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

示例1: PropertyEmitter

		public PropertyEmitter(TypeBuilder owner, string name, Type propertyType, FieldBuilder propertyChangedField) {
			this.owner = owner;
			this.propertyChangedField = propertyChangedField;
			fieldBuilder = owner.DefineField(String.Format("<{0}>", name), propertyType, FieldAttributes.Private);
			getterBuilder = owner.DefineMethod(String.Format("get_{0}", name), MethodAttributes.Public|MethodAttributes.Virtual|MethodAttributes.HideBySig|MethodAttributes.SpecialName, propertyType, Type.EmptyTypes);
			ILGenerator getterIl = getterBuilder.GetILGenerator();
			getterIl.Emit(OpCodes.Ldarg_0);
			getterIl.Emit(OpCodes.Ldfld, fieldBuilder);
			getterIl.Emit(OpCodes.Ret);
			setterBuilder = owner.DefineMethod(String.Format("set_{0}", name), MethodAttributes.Public|MethodAttributes.Virtual|MethodAttributes.HideBySig|MethodAttributes.SpecialName, typeof(void), new[] {propertyType});
			ILGenerator setterIl = setterBuilder.GetILGenerator();
			setterIl.Emit(OpCodes.Ldarg_0);
			setterIl.Emit(OpCodes.Ldarg_1);
			setterIl.Emit(OpCodes.Stfld, fieldBuilder);
			if (propertyChangedField != null) {
				setterIl.Emit(OpCodes.Ldarg_0);
				setterIl.Emit(OpCodes.Dup);
				setterIl.Emit(OpCodes.Ldfld, propertyChangedField);
				setterIl.Emit(OpCodes.Ldstr, name);
				setterIl.Emit(OpCodes.Call, proxyBase_NotifyPropertyChanged);
			}
			setterIl.Emit(OpCodes.Ret);
			propertyBuilder = owner.DefineProperty(name, PropertyAttributes.None, propertyType, null);
			propertyBuilder.SetGetMethod(getterBuilder);
			propertyBuilder.SetSetMethod(setterBuilder);
		}
开发者ID:NicoGBN,项目名称:AutoMapper,代码行数:26,代码来源:PropertyEmitter.cs

示例2: GetterMethodFor

        internal static MethodBuilder GetterMethodFor(TypeBuilder typeBuilder,
            PropertyBuilder property, MethodAttributes access)
        {
            var getterMethod = typeBuilder.DefineMethod("get_" + property.Name,
                                                        access, property.PropertyType, null);

            property.SetGetMethod(getterMethod);
            return getterMethod;
        }
开发者ID:gamlerhart,项目名称:db4opad,代码行数:9,代码来源:CodeGenerationUtils.cs

示例3: BuildGetter

        private void BuildGetter(TypeBuilder typeBuilder, PropertyInfo contractProperty, PropertyBuilder builder)
        {
            var getMethod = contractProperty.GetGetMethod();

            if(null != getMethod)
            {
                var getMethodBuilder = new ProxyMethodImplementationStrategy().BuildMethodProxy(typeBuilder, getMethod);
                builder.SetGetMethod(getMethodBuilder);
            }
        }
开发者ID:fkalseth,项目名称:tinyaop,代码行数:10,代码来源:ProxyPropertyImplementationStrategy.cs

示例4: AddGetter

 private void AddGetter(System.Reflection.Emit.TypeBuilder typeBuilder, FieldBuilder fieldBuilder, PropertyBuilder propertyBuilder)
 {
     MethodBuilder propertyGetter = typeBuilder.DefineMethod("get_" + _propertyName,
                          MethodAttributes.Public |
                         MethodAttributes.SpecialName |
                         MethodAttributes.HideBySig,
                         _propertyType, Type.EmptyTypes);
     var ilGenerator = propertyGetter.GetILGenerator();
     ilGenerator.Emit(OpCodes.Ldarg_0);
     ilGenerator.Emit(OpCodes.Ldfld, fieldBuilder);
     ilGenerator.Emit(OpCodes.Ret);
     propertyBuilder.SetGetMethod(propertyGetter);
 }
开发者ID:RichieYang,项目名称:NHateoas,代码行数:13,代码来源:PropertyVisitor.cs

示例5: CreateGetMethod

        /// <summary>
        /// Creates the get method.
        /// </summary>
        /// <param name="typeBuilder">The type builder.</param>
        /// <param name="prop">The prop.</param>
        /// <param name="fieldBuilder">The field builder.</param>
        /// <param name="propBuilder">The prop builder.</param>
        private static void CreateGetMethod(TypeBuilder typeBuilder, PropertyInfo prop, FieldInfo fieldBuilder, PropertyBuilder propBuilder)
        {
            var getMethodBuilder = typeBuilder.DefineMethod(
                "get_" + prop.Name,
                GetSetAttributes,
                prop.PropertyType,
                Type.EmptyTypes);

            var getIl = getMethodBuilder.GetILGenerator();
            getIl.Emit(OpCodes.Ldarg_0);
            getIl.Emit(OpCodes.Ldfld, fieldBuilder);
            getIl.Emit(OpCodes.Ret);
            propBuilder.SetGetMethod(getMethodBuilder);
        }
开发者ID:petxo,项目名称:HermEsb,代码行数:21,代码来源:DynamicPropertyBuilder.cs

示例6: AddGetter

 private void AddGetter(System.Reflection.Emit.TypeBuilder typeBuilder, PropertyBuilder propertyBuilder)
 {
     MethodBuilder propertyGetter = typeBuilder.DefineMethod("get_" + _propertyInfo.Name,
         MethodAttributes.Public |
         MethodAttributes.SpecialName |
         MethodAttributes.HideBySig,
         _propertyInfo.PropertyType, Type.EmptyTypes);
     var ilGenerator = propertyGetter.GetILGenerator();
     ilGenerator.Emit(OpCodes.Ldarg_0);
     ilGenerator.Emit(OpCodes.Ldfld, _aggregate);
     MethodInfo getter = _propertyInfo.GetAccessors().First(accessor => accessor.ReturnType != typeof (void));
     ilGenerator.Emit(OpCodes.Callvirt, getter);
     ilGenerator.Emit(OpCodes.Ret);
     propertyBuilder.SetGetMethod(propertyGetter);
 }
开发者ID:RichieYang,项目名称:NHateoas,代码行数:15,代码来源:AggregatedPropertyVisitor.cs

示例7: CreateGetter

        private static void CreateGetter(TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, DataColumn column)
        {
            var getMethodBuilder = typeBuilder.DefineMethod(
                "get_" + column.ColumnName,
                MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName,
                CallingConventions.HasThis,
                column.DataType, Type.EmptyTypes);

            var getMethodIL = getMethodBuilder.GetILGenerator();
            getMethodIL.Emit(OpCodes.Ldarg_0);
            getMethodIL.Emit(OpCodes.Ldstr, column.ColumnName);
            getMethodIL.Emit(OpCodes.Callvirt, GetValueMethod.MakeGenericMethod(column.DataType));
            getMethodIL.Emit(OpCodes.Ret);

            propertyBuilder.SetGetMethod(getMethodBuilder);
        }
开发者ID:FoundOPS,项目名称:server,代码行数:16,代码来源:DynamicObjectBuilder.cs

示例8: EmitBaseGetter

            private static void EmitBaseGetter(TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, PropertyInfo baseProperty)
            {
                if (CanProxyGetter(baseProperty))
                {
                    var baseGetter = baseProperty.GetGetMethod(true);
                    const MethodAttributes getterAttributes =
                        MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Virtual;
                    var getterAccess = baseGetter.Attributes & MethodAttributes.MemberAccessMask;

                    // Define a property getter override in the proxy type
                    var getterBuilder = typeBuilder.DefineMethod(
                        "get_" + baseProperty.Name, getterAccess | getterAttributes, baseProperty.PropertyType, Type.EmptyTypes);
                    var gen = getterBuilder.GetILGenerator();

                    gen.Emit(OpCodes.Ldarg_0);
                    gen.Emit(OpCodes.Call, baseGetter);
                    gen.Emit(OpCodes.Ret);

                    propertyBuilder.SetGetMethod(getterBuilder);
                }
            }
开发者ID:christiandpena,项目名称:entityframework,代码行数:21,代码来源:EntityProxyFactory.cs

示例9: GenerateProxyMethod


//.........这里部分代码省略.........
            case TypeTag.Int16:
            case TypeTag.UInt8:
            case TypeTag.UInt16:
            case TypeTag.Char:
            case TypeTag.WChar:
            case TypeTag.UInt32:
                EmitPrepareArgStore(i);
                // XXX do I need to cast this?
                ilg.Emit(OpCodes.Castclass, typeof(Int32));
                ilg.Emit(OpCodes.Stind_I4);
                break;
            case TypeTag.Int32:
                EmitPrepareArgStore(i);
                ilg.Emit(OpCodes.Stind_I4);
                break;
            case TypeTag.NSIdPtr:
                EmitPrepareArgStore(i);
                ilg.Emit(OpCodes.Stind_I4); // XXX 64-bitness
                break;
            case TypeTag.String:
                EmitPrepareArgStore(i);
                // the string arg is now on the stack
                ilg.Emit(OpCodes.Call,
                         marshalType.GetMethod("StringToCoTaskMemAnsi"));
                ilg.Emit(OpCodes.Stind_I4);
                break;
            case TypeTag.Interface:
                EmitPrepareArgStore(i);
                // MRP is the object passed as this arg
                ilg.Emit(OpCodes.Ldloca_S, guidLocal);
                ilg.Emit(OpCodes.Ldstr, param.GetIID().ToString());
                ilg.Emit(OpCodes.Call, guidCtor);
                ilg.Emit(OpCodes.Ldloca_S, guidLocal);
                // stack is now objarg, ref guid
                ilg.Emit(OpCodes.Call, typeof(CLRWrapper).GetMethod("Wrap"));
                // now stack has the IntPtr in position to be stored.
                ilg.Emit(OpCodes.Stind_I4);
                break;
            default:
                /*
                String msg = String.Format("{0}: type {1} not supported",
                                    param.Name(), type.tag.ToString());
                throw new Exception(msg);
                */
                break;
            }
            EmitPtrAndFlagsStore(i, ptr, flags);
            }

            //= (void)XPTC_InvokeByIndex(thisptr, desc.index, length, bufLocal);
            ilg.Emit(OpCodes.Ldarg_0);
            ilg.Emit(OpCodes.Ldfld, thisField);
            ilg.Emit(OpCodes.Ldc_I4, desc.index);
            ilg.Emit(OpCodes.Ldc_I4, args.Length);
            ilg.Emit(OpCodes.Ldloc_0);
            ilg.Emit(OpCodes.Call, typeof(Mozilla.XPCOM.Invoker).
                 GetMethod("XPTC_InvokeByIndex",
                           BindingFlags.Static | BindingFlags.NonPublic));
            ilg.Emit(OpCodes.Pop);

            if (ret == typeof(string)) {
            ilg.Emit(OpCodes.Ldstr, "FAKE RETURN STRING");
            } else if (ret == typeof(object)) {
            ilg.Emit(OpCodes.Newobj,
                     typeof(object).GetConstructor(new Type[0]));
            } else if (ret == typeof(int)) {
            EmitLoadReturnSlot_1(args.Length);
            } else if (ret == typeof(void)) {
            // Nothing
            } else {
            throw new Exception(String.Format("return type {0} not " +
                                              "supported yet",
                                              desc.result.type.tag));
            }

            //= Marshal.FreeCoTaskMem(bufLocal);
            ilg.Emit(OpCodes.Ldloc, bufLocal);
            ilg.Emit(OpCodes.Call, marshalType.GetMethod("FreeCoTaskMem"));

            ilg.Emit(OpCodes.Ret);

            ilg = null;
            bufLocal = null;

            if (desc.IsSetter()) {
            if (lastProperty != null && lastProperty.Name == desc.name) {
                lastProperty.SetSetMethod(meth);
            } else {
                tb.DefineProperty(desc.name, PROPERTY_ATTRS, desc.resultType,
                                  new Type[0]).SetSetMethod(meth);
            }
            lastProperty = null;
            } else if (desc.IsGetter()) {
            lastProperty = tb.DefineProperty(desc.name, PROPERTY_ATTRS,
                                             desc.resultType, new Type[0]);
            lastProperty.SetGetMethod(meth);
            } else {
            lastProperty = null;
            }
        }
开发者ID:nfan,项目名称:Jaxer,代码行数:101,代码来源:proxy-generator.cs

示例10: CreateListTypeAndListCreatorMethod

        /* deprecated
        //IL:
        //     L_0000: newobj instance void Vita.Framework.EntityListProxy`1<class Vita.Framework.SampleEntityImpl.ISampleEntity>::.ctor()
        //
        private void CreateListTypeAndListCreatorMethod(EntityInfo entityInfo, TypeBuilder entityTypeBuilder) {
          //Construct concrete list type from generic EntityListProxy<> type
          var listGenericType = typeof(ObservableEntityList<>);
          entityInfo.ClassInfo.ListType = listGenericType.MakeGenericType(entityInfo.EntityType);
          var listConstr = entityInfo.ClassInfo.ListType.GetConstructor(Type.EmptyTypes);
          //Now create static factory method
          var methFlags = MethodAttributes.Static | MethodAttributes.Public;
          var createListProxyBuilder = entityTypeBuilder.DefineMethod(ListProxyCreatorMethodName, methFlags, typeof(IList), Type.EmptyTypes);
          var ilGen = createListProxyBuilder.GetILGenerator();
          ilGen.Emit(OpCodes.Newobj, listConstr);
          ilGen.Emit(OpCodes.Ret);

        }
        */
        /* Getter IL
          IL_0000: ldarg.0
          IL_0001: ldfld ns.EntityBase::Record
          IL_0006: ldc.i4.1
          IL_0007: callvirt instance object ExperimentsApp.StaticMembers.EntityRecord::GetValue(int32)
          IL_000c: castclass [mscorlib]System.String
          IL_0011: ret
          */
        private MethodBuilder CreateGetter(TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, int memberIndex, 
            string name = null, bool asPublic = true)
        {
            var getterName = name ?? "get_" + propertyBuilder.Name;
              var attrs = MethodAttributes.SpecialName | MethodAttributes.Virtual | MethodAttributes.HideBySig;
              if (asPublic)
            attrs |= MethodAttributes.Public;
              else
            attrs |= MethodAttributes.Private;
              var propType = propertyBuilder.PropertyType;
              var getter = typeBuilder.DefineMethod(getterName, attrs, propType, Type.EmptyTypes);
              var ilGen = getter.GetILGenerator();
              ilGen.Emit(OpCodes.Ldarg_0);
              ilGen.Emit(OpCodes.Ldfld, _entityBase_Record);
              ilGen.Emit(OpCodes.Ldc_I4, memberIndex);
              ilGen.Emit(OpCodes.Call, _entityRecord_GetValue);
              if (propType.IsValueType) // || propType.IsEnum)
            ilGen.Emit(OpCodes.Unbox_Any, propType);
              else
            ilGen.Emit(OpCodes.Castclass, propType);
              ilGen.Emit(OpCodes.Ret);
              propertyBuilder.SetGetMethod(getter);
              return getter;
        }
开发者ID:yuanfei05,项目名称:vita,代码行数:50,代码来源:EntityClassBuilder.cs

示例11: SetAccessors

 private static void SetAccessors(PropertyBuilder property, IEnumerable<RppMethodInfo> methods)
 {
     string propertyName = property.Name;
     foreach (RppMethodInfo method in methods)
     {
         if (method.Name == RppMethodInfo.GetGetterAccessorName(propertyName))
         {
             property.SetGetMethod((MethodBuilder) method.Native);
         }
         else if (method.Name == RppMethodInfo.GetSetterAccessorName(propertyName))
         {
             property.SetSetMethod((MethodBuilder) method.Native);
         }
     }
 }
开发者ID:dubik,项目名称:csharprpp,代码行数:15,代码来源:RType.cs

示例12: DefineGetMethod

        private static void DefineGetMethod(TypeBuilder newType, PropertyBuilder propertyBuilder, FieldInfo fieldBuilder, PropertyInfo property)
        {
            var getMethod = property.GetGetMethod();
            var methodBuilder = newType.DefineMethod(getMethod.Name,
                                                     MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Virtual,
                                                     property.PropertyType,
                                                     Type.EmptyTypes);

            var ilg = methodBuilder.GetILGenerator();

            ilg.Emit(OpCodes.Ldarg_0);
            ilg.Emit(OpCodes.Ldfld, fieldBuilder);
            ilg.Emit(OpCodes.Ret);

            propertyBuilder.SetGetMethod(methodBuilder);

            var methodInfo = methodBuilder.GetBaseDefinition();

            newType.DefineMethodOverride(methodInfo, getMethod);
        }
开发者ID:mcwatt77,项目名称:vimcontrols,代码行数:20,代码来源:ImplementationBuilder.cs

示例13: DefineBuilders

		protected void DefineBuilders (MemberKind kind, ParametersCompiled parameters)
		{
			PropertyBuilder = Parent.TypeBuilder.DefineProperty (
				GetFullName (MemberName), PropertyAttributes.None,
#if !BOOTSTRAP_BASIC	// Requires trunk version mscorlib
				IsStatic ? 0 : CallingConventions.HasThis,
#endif
				MemberType.GetMetaInfo (), null, null,
				parameters.GetMetaInfo (), null, null);

			PropertySpec spec;
			if (kind == MemberKind.Indexer)
				spec = new IndexerSpec (Parent.Definition, this, MemberType, parameters, PropertyBuilder, ModFlags);
			else
				spec = new PropertySpec (kind, Parent.Definition, this, MemberType, PropertyBuilder, ModFlags);

			if (Get != null) {
				spec.Get = Get.Spec;

				var method = Get.Spec.GetMetaInfo () as MethodBuilder;
				if (method != null) {
					PropertyBuilder.SetGetMethod (method);
					Parent.MemberCache.AddMember (this, method.Name, Get.Spec);
				}
			} else {
				CheckMissingAccessor (kind, parameters, true);
			}

			if (Set != null) {
				spec.Set = Set.Spec;

				var method = Set.Spec.GetMetaInfo () as MethodBuilder;
				if (method != null) {
					PropertyBuilder.SetSetMethod (method);
					Parent.MemberCache.AddMember (this, method.Name, Set.Spec);
				}
			} else {
				CheckMissingAccessor (kind, parameters, false);
			}

			Parent.MemberCache.AddMember (this, PropertyBuilder.Name, spec);
		}
开发者ID:afaerber,项目名称:mono,代码行数:42,代码来源:property.cs

示例14: DefinePropertyGetter

        private void DefinePropertyGetter(Entity c, Entity p, TypeBuilder t, bool forward, string propname, Type rettype, Type retelemtype, bool functional, PropertyBuilder property)
        {
            MethodBuilder method = t.DefineMethod("get_" + propname,
                MethodAttributes.Public | MethodAttributes.SpecialName,
                CallingConventions.HasThis,
                rettype, Type.EmptyTypes);
            property.SetGetMethod(method);

            ILGenerator il = method.GetILGenerator();

            il.DeclareLocal(typeof(ArrayList));
            il.DeclareLocal(typeof(int));
            if (retelemtype == typeof(string))
                il.DeclareLocal(typeof(string));
            else
                il.DeclareLocal(typeof(Entity));

            if (!functional) {
                // Create array list in local variable 0
                il.Emit(OpCodes.Newobj, arraylistconstructor);
                il.Emit(OpCodes.Stloc_0);
            }

            // Push model (arg 0 of Select)
            il.Emit(OpCodes.Ldarg_0);
            il.Emit(OpCodes.Call, getmodel);

            if (forward) {
                // Push entity (arg 1 to Select)
                il.Emit(OpCodes.Ldarg_0);
                il.Emit(OpCodes.Call, getentity);

                // Push property (arg 2 to Select)
                il.Emit(OpCodes.Ldstr, p.Uri);
                il.Emit(OpCodes.Newobj, newentity);
            } else {
                // Push property (arg 1 to Select)
                il.Emit(OpCodes.Ldstr, p.Uri);
                il.Emit(OpCodes.Newobj, newentity);

                // Push entity (arg 2 to Select)
                il.Emit(OpCodes.Ldarg_0);
                il.Emit(OpCodes.Call, getentity);
            }

            // Call select (pushes Resource[] or Entity[])

            if (forward)
                il.Emit(OpCodes.Call, selectobjects);
            else
                il.Emit(OpCodes.Call, selectsubjects);

            // Loop through the statements

            Label loopstart = il.DefineLabel();
            Label loopend = il.DefineLabel();
            Label loopcontinue = il.DefineLabel();
            il.Emit(OpCodes.Ldc_I4_0); // initialize counter local var 1
            il.Emit(OpCodes.Stloc_1);

            il.MarkLabel(loopstart);
            il.Emit(OpCodes.Dup); // dup the array
            il.Emit(OpCodes.Ldlen); // push length of array
            il.Emit(OpCodes.Ldloc_1); // push counter
            il.Emit(OpCodes.Ble, loopend);

            il.Emit(OpCodes.Dup); // dup the array
            il.Emit(OpCodes.Ldloc_1); // push counter
            il.Emit(OpCodes.Ldelem_Ref);	// pop array, counter, push element

            // Ensure value is of the right type
            if (retelemtype == typeof(string)) {
                // Literal value
                il.Emit(OpCodes.Isinst, typeof(Literal));
                il.Emit(OpCodes.Brfalse, loopcontinue);
            } else if (forward) { // if !forward, it must be an entity
                // Ensure entity value
                il.Emit(OpCodes.Isinst, typeof(Entity));
                il.Emit(OpCodes.Brfalse, loopcontinue);
            }

            // Because of the br, we've lost the object reference -- load it again

            il.Emit(OpCodes.Dup); // dup the array
            il.Emit(OpCodes.Ldloc_1); // push counter
            il.Emit(OpCodes.Ldelem_Ref);	// pop array, counter, push element

            // Get the value we want to return
            if (retelemtype == typeof(string)) {
                // Cast to literal, replace it with its value
                il.Emit(OpCodes.Castclass, typeof(Literal));
                il.Emit(OpCodes.Call, literalvalue);
            } else {
                // Cast to entity, push model, replace with bound type
                il.Emit(OpCodes.Castclass, typeof(Entity));

                il.Emit(OpCodes.Ldarg_0); // model
                il.Emit(OpCodes.Call, getmodel);

                ConstructorInfo ctor = GetConstructor(retelemtype);
//.........这里部分代码省略.........
开发者ID:JoshData,项目名称:semweb-dotnet,代码行数:101,代码来源:rdfbind.cs

示例15: CreatePropertyGetMethod

        /// <summary>
        /// Creates the body of a property getter
        /// </summary>
        /// <param name="generatedTypeBuilder"></param>
        /// <param name="p"></param>
        /// <param name="property"></param>
        /// <param name="getDecl"></param>
        /// <param name="logicField"></param>
        private void CreatePropertyGetMethod(TypeBuilderHelper generatedTypeBuilder, PropertyInfo p,
                                             PropertyBuilder property, MethodInfo getDecl, FieldInfo logicField)
        {
            //set setter name and return type
            var setterName = getDecl == null ? "get_" + p.Name : getDecl.Name;
            var returnType = getDecl == null ? p.PropertyType : getDecl.ReturnType;

            //determine security attributes
            var methodAttributes = MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Virtual;

            //create setter method
            var getBuilder = generatedTypeBuilder.DefineMethod(setterName, methodAttributes, returnType, null);

            //emit IL opcode
            getBuilder
                .Emitter
                .nop
                .ldarg_0
                .ldfld(logicField)
                .ldstr(p.Name)
                //this.LogicBase<[logicField.FieldType]>.GetProperty([methodName])
                .callvirt(Reflect<LogicBase>.GetMethod(x => x.GetProperty<object>(string.Empty)).MakeGenericMethod(p.PropertyType))
                .ret();

            //apply the created method to the getter
            property.SetGetMethod(getBuilder);
        }
开发者ID:pietervp,项目名称:MData,代码行数:35,代码来源:TypeCreator.cs


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