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


C# Emit.PropertyBuilder类代码示例

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


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

示例1: CreateNewInstanceGetter

        static MethodBuilder CreateNewInstanceGetter(TypeBuilder typeBuilder, PropertyBuilder property, 
            ConstructorInfo constructor, MethodAttributes accessRights)
        {
            var getterMethod = CodeGenerationUtils.GetterMethodFor(typeBuilder, property, accessRights);

            CodeGenerationUtils.ReturnNewInstanceILInstructions(constructor, getterMethod);
            return getterMethod;
        }
开发者ID:gamlerhart,项目名称:db4opad,代码行数:8,代码来源:NamespaceContextGenerator.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: BuildSetter

        private void BuildSetter(TypeBuilder typeBuilder, PropertyInfo contractProperty, PropertyBuilder builder)
        {
            var setMethod = contractProperty.GetSetMethod();

            if (null != setMethod)
            {
                var setMethodBuilder = new ProxyMethodImplementationStrategy().BuildMethodProxy(typeBuilder, setMethod);
                builder.SetSetMethod(setMethodBuilder);
            }
        }
开发者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: AddSetter

 private void AddSetter(System.Reflection.Emit.TypeBuilder typeBuilder, FieldBuilder fieldBuilder, PropertyBuilder propertyBuilder)
 {
     MethodBuilder propertySetter = typeBuilder.DefineMethod("set_" + _propertyName,
                          MethodAttributes.Public |
                         MethodAttributes.SpecialName |
                         MethodAttributes.HideBySig,
                         null, new Type[] { _propertyType });
     var propertySetterIl = propertySetter.GetILGenerator();
     propertySetterIl.Emit(OpCodes.Ldarg_0);
     propertySetterIl.Emit(OpCodes.Ldarg_1);
     propertySetterIl.Emit(OpCodes.Stfld, fieldBuilder);
     propertySetterIl.Emit(OpCodes.Ret);
     propertyBuilder.SetSetMethod(propertySetter);
 }
开发者ID:RichieYang,项目名称:NHateoas,代码行数:14,代码来源:PropertyVisitor.cs

示例6: 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

示例7: 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

示例8: CreateGetter

        /// <summary>
        /// Creates the getter.
        /// </summary>
        /// <param name="typeBuilder">The type builder.</param>
        /// <param name="propertyBuilder">The property builder.</param>
        /// <param name="column">The column.</param>
        private static void CreateGetter(TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, SLDataColumn 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:K-Library-NET,项目名称:PopcornStudios,代码行数:22,代码来源:DynamicObjectBuilder.cs

示例9: CreateSetMethod

        /// <summary>
        /// Creates the set 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 CreateSetMethod(TypeBuilder typeBuilder, PropertyInfo prop, FieldInfo fieldBuilder, PropertyBuilder propBuilder)
        {
            var setMethodBuilder = typeBuilder.DefineMethod(
                "set_" + prop.Name,
                GetSetAttributes,
                null,
                new[] { prop.PropertyType });

            var setIl = setMethodBuilder.GetILGenerator();
            setIl.Emit(OpCodes.Ldarg_0);
            setIl.Emit(OpCodes.Ldarg_1);
            setIl.Emit(OpCodes.Stfld, fieldBuilder);
            setIl.Emit(OpCodes.Ret);

            propBuilder.SetSetMethod(setMethodBuilder);
        }
开发者ID:petxo,项目名称:HermEsb,代码行数:23,代码来源:DynamicPropertyBuilder.cs

示例10: AddSetter

 private void AddSetter(System.Reflection.Emit.TypeBuilder typeBuilder, PropertyBuilder propertyBuilder)
 {
     MethodBuilder propertySetter = typeBuilder.DefineMethod("set_" + _propertyInfo.Name,
                          MethodAttributes.Public |
                         MethodAttributes.SpecialName |
                         MethodAttributes.HideBySig,
                         null, new Type[] { _propertyInfo.PropertyType });
     var propertySetterIl = propertySetter.GetILGenerator();
     propertySetterIl.Emit(OpCodes.Ldarg_0);
     propertySetterIl.Emit(OpCodes.Ldfld, _aggregate);
     propertySetterIl.Emit(OpCodes.Ldarg_1);
     MethodInfo setter = _propertyInfo.GetAccessors().First(accessor => accessor.ReturnType == typeof(void));
     propertySetterIl.Emit(OpCodes.Callvirt, setter);
     propertySetterIl.Emit(OpCodes.Ret);
     propertyBuilder.SetSetMethod(propertySetter);
 }
开发者ID:RichieYang,项目名称:NHateoas,代码行数:16,代码来源:AggregatedPropertyVisitor.cs

示例11: CreateGetter

        private static void CreateGetter(TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, IPropertyInfo propertyInfo)
        {
            MethodBuilder getMethodBuilder = typeBuilder.DefineMethod(
                "get_" + propertyInfo.PropertyName,
                MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName,
                CallingConventions.HasThis,
                propertyInfo.PropertyType, Type.EmptyTypes);

            ILGenerator getMethodIL = getMethodBuilder.GetILGenerator();
            getMethodIL.Emit(OpCodes.Ldarg_0);
            getMethodIL.Emit(OpCodes.Ldstr, propertyInfo.PropertyName);
            getMethodIL.Emit(OpCodes.Callvirt, GetValueMethod.MakeGenericMethod(propertyInfo.PropertyType));
            getMethodIL.Emit(OpCodes.Ret);

            propertyBuilder.SetGetMethod(getMethodBuilder);
        }
开发者ID:mehmetgoren,项目名称:AppX.Data,代码行数:16,代码来源:RecordBuilder.cs

示例12: CreateSetter

        private static void CreateSetter(TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, IPropertyInfo propertyInfo)
        {
            MethodBuilder setMethodBuilder = typeBuilder.DefineMethod(
                "set_" + propertyInfo.PropertyName,
                MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName,
                CallingConventions.HasThis,
                null, new[] { propertyInfo.PropertyType });

            ILGenerator setMethodIL = setMethodBuilder.GetILGenerator();
            setMethodIL.Emit(OpCodes.Ldarg_0);
            setMethodIL.Emit(OpCodes.Ldstr, propertyInfo.PropertyName);
            setMethodIL.Emit(OpCodes.Ldarg_1);
            setMethodIL.Emit(OpCodes.Callvirt, SetValueMethod.MakeGenericMethod(propertyInfo.PropertyType));
            setMethodIL.Emit(OpCodes.Ret);

            propertyBuilder.SetSetMethod(setMethodBuilder);
        }
开发者ID:mehmetgoren,项目名称:AppX.Data,代码行数:17,代码来源:RecordBuilder.cs

示例13: CreateSetter

        private static void CreateSetter(TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, DataColumn column)
        {
            var setMethodBuilder = typeBuilder.DefineMethod(
                "set_" + column.ColumnName,
                MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName,
                CallingConventions.HasThis,
                null, new[] { column.DataType });

            var setMethodIL = setMethodBuilder.GetILGenerator();
            setMethodIL.Emit(OpCodes.Ldarg_0);
            setMethodIL.Emit(OpCodes.Ldstr, column.ColumnName);
            setMethodIL.Emit(OpCodes.Ldarg_1);
            setMethodIL.Emit(OpCodes.Callvirt, SetValueMethod.MakeGenericMethod(column.DataType));
            setMethodIL.Emit(OpCodes.Ret);

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

示例14: EmitAttribute

		public void EmitAttribute (PropertyBuilder builder)
		{
			if (ResolveBuilder ())
				builder.SetCustomAttribute (cab);
		}
开发者ID:alisci01,项目名称:mono,代码行数:5,代码来源:attribute.cs

示例15: PropertyEmitter

        // private ParameterInfo[] indexParameters;
        public PropertyEmitter(AbstractTypeEmitter parentTypeEmitter, String name, PropertyAttributes attributes,
		                       Type propertyType)
        {
            this.parentTypeEmitter = parentTypeEmitter;

            builder = parentTypeEmitter.TypeBuilder.DefineProperty(name, attributes, propertyType, new Type[0]);
        }
开发者ID:havard,项目名称:strongbind,代码行数:8,代码来源:PropertyEmitter.cs


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