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


C# PropertyBuilder.SetCustomAttribute方法代码示例

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


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

示例1: CloneCustomAttributes

 private void CloneCustomAttributes(PropertyBuilder property, EntityMemberInfo member)
 {
     foreach(var attr in member.Attributes) {
     CustomAttributeHandler handler;
     if (!_model.App.AttributeHandlers.TryGetValue(attr.GetType(), out handler)) continue;
     var attrBuilder = handler.Clone(attr);
     if (attrBuilder != null)
       property.SetCustomAttribute(attrBuilder);
       }
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:10,代码来源:EntityClassBuilder.cs

示例2: AddCustomAttributeToProperty

 /// <summary>
 /// Given a custom attribute and property builder, adds an instance of custom attribute
 /// to the property builder
 /// </summary>
 void AddCustomAttributeToProperty(object customAttribute, PropertyBuilder propBuilder)
 {
     var customAttributeBuilder = BuildCustomAttribute(customAttribute);
     if (customAttributeBuilder != null)
     {
         propBuilder.SetCustomAttribute(customAttributeBuilder);
     }
 }
开发者ID:AdrianFreemantle,项目名称:Hermes,代码行数:12,代码来源:TypeMapper.cs

示例3: SetAttributes

        private static void SetAttributes(PropertyBuilder propertyBuilder, MemberInfo memberInfo)
        {
            var customAttributeBuilders = PropertyAttributeBuilders
                .GetOrAdd(
                    memberInfo,
                    p =>
                    {
                        var customAttributes = p.GetCustomAttributesData();
                        return CreateCustomAttributeBuilders(customAttributes).ToArray();
                    });

            Contract.Assume(customAttributeBuilders != null);

            foreach (var attribute in customAttributeBuilders)
            {
                propertyBuilder.SetCustomAttribute(attribute);
            }
        }
开发者ID:calebjenkins,项目名称:Highway.Data,代码行数:18,代码来源:RuntimeTypeProvider.cs

示例4: EmitAttribute

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

示例5: SetDataMemberAttribute

        private static void SetDataMemberAttribute(PropertyBuilder typeBuilder)
        {
            var dmbType = typeof(DataMemberAttribute);
            var dataMemberBuilder = new CustomAttributeBuilder(
                dmbType.GetConstructor(Type.EmptyTypes), new object[0]);

            typeBuilder.SetCustomAttribute(dataMemberBuilder);
        }
开发者ID:petxo,项目名称:HermEsb,代码行数:8,代码来源:DynamicPropertyBuilder.cs

示例6: EmitAttribute

		public void EmitAttribute (PropertyBuilder builder, TypeSpec type)
		{
			if (ResolveTransformationCtor ()) {
				var cab = new CustomAttributeBuilder ((ConstructorInfo) tctor.GetMetaInfo (), new object[] { GetTransformationFlags (type) });
				builder.SetCustomAttribute (cab);
			}
		}
开发者ID:Ein,项目名称:monodevelop,代码行数:7,代码来源:attribute.cs

示例7: EmitCustomAttributes

 private void EmitCustomAttributes(PropertyBuilder propertyBuilder, IEnumerable<Cci.ICustomAttribute> attributes)
 {
     foreach (var attribute in attributes)
     {
         propertyBuilder.SetCustomAttribute(CreateCustomAttributeBuilder(attribute));
     }
 }
开发者ID:furesoft,项目名称:roslyn,代码行数:7,代码来源:ReflectionEmitter.cs

示例8: createHashMethod

        private void createHashMethod(PropertyBuilder propBuild,TypeBuilder typeBuild,FieldBuilder hash)
        {
            // First, we'll define the behavior of the "get" property for Hash as a method.
            MethodBuilder typeHashGet = typeBuild.DefineMethod("GetHash",
                MethodAttributes.Public,
                typeof(Hashtable),
                new Type[] { });
            ILGenerator ilg = typeHashGet.GetILGenerator();
            ilg.Emit(OpCodes.Ldarg_0);
            ilg.Emit(OpCodes.Ldfld, hash);
            ilg.Emit(OpCodes.Ret);

            // Now, we'll define the behavior of the "set" property for Hash.
            MethodBuilder typeHashSet = typeBuild.DefineMethod("SetHash",
                MethodAttributes.Public,
                null,
                new Type[] { typeof(Hashtable) });

            ilg = typeHashSet.GetILGenerator();
            ilg.Emit(OpCodes.Ldarg_0);
            ilg.Emit(OpCodes.Ldarg_1);
            ilg.Emit(OpCodes.Stfld, hash);
            ilg.Emit(OpCodes.Ret);

            // map the two methods created above to their property
            propBuild.SetGetMethod(typeHashGet);
            propBuild.SetSetMethod(typeHashSet);

            //add the [Browsable(false)] property to the Hash property so it doesnt show up on the property list
            ConstructorInfo ci = typeof(BrowsableAttribute).GetConstructor(new Type[]{typeof(bool)});
            CustomAttributeBuilder cab = new CustomAttributeBuilder(ci,new object[]{false});
            propBuild.SetCustomAttribute(cab);
        }
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:33,代码来源:CustomPropertyGrid.cs

示例9: SetAttributes

        /// <summary>
        /// Establece los atributos para la propiedad indicada
        /// </summary>
        /// <param name="propertyBuilder">Constructor de propiedades</param>
        /// <param name="propertyInfo">Información de la propiedad</param>
        private void SetAttributes( PropertyBuilder propertyBuilder, PropertyInfo propertyInfo )
        {
            Verify.ArgumentNotNull(propertyBuilder, "propertyBuilder");
            Verify.ArgumentNotNull(propertyInfo, "propertyInfo");

            var propBuilders = PropertyAttributeBuilders
                .GetOrAdd(propertyInfo,
                          p =>
                          {
                              var customAttr = p.GetCustomAttributesData();
                              return CreateCustomAttributeBuilders(customAttr);
                          })
                .ToList();

            propBuilders.ForEach(pb => propertyBuilder.SetCustomAttribute(pb));
        }
开发者ID:jdmartinez,项目名称:Northwind,代码行数:21,代码来源:ClassFactory.cs

示例10: SetAttributes

        private static void SetAttributes(KeyValuePair<string, IMetadataDefinition> pair, PropertyBuilder prop)
        {
            prop.SetCustomAttribute(
                new CustomAttributeBuilder(
                    JsonPropertyAttributeCtor,
                    new object[] { pair.Key },
                    new[] { JsonPropertyAttribute_Required },
                    new object[] { pair.Value.IsRequired ? Required.Always : Required.Default }));

            prop.SetCustomAttribute(
                new CustomAttributeBuilder(
                    DisplayNameAttribute_Ctor,
                    new object[] { pair.Value.DisplayName }));

            if (pair.Value.IsQueryable)
            {
                prop.SetCustomAttribute(
                    new CustomAttributeBuilder(
                        QueryNameAttribute_Ctor,
                        new object[] { pair.Value.QueryName }));
            }
        }
开发者ID:ansyral,项目名称:docfx,代码行数:22,代码来源:MetadataCompiler.cs

示例11: AddFromIdlNameAttribute

 private void AddFromIdlNameAttribute(PropertyBuilder propBuild, string forIdlAttributeName) {
     propBuild.SetCustomAttribute(
         new FromIdlNameAttribute(forIdlAttributeName).CreateAttributeBuilder());
 }        
开发者ID:JnS-Software-LLC,项目名称:iiop-net,代码行数:4,代码来源:ILEmitHelper.cs

示例12: AssociateAttribute

 private void AssociateAttribute(PropertyBuilder propertyBuilder, Type attributeType, string value)
 {
     CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(
         attributeType.GetConstructor(new Type[] { typeof(string) }),
         new object[] { value });
     propertyBuilder.SetCustomAttribute(attributeBuilder);
 }
开发者ID:robrich,项目名称:CruiseControl.NET,代码行数:7,代码来源:BuildParameters.cs

示例13: DefineCustomAttributes

 internal static void DefineCustomAttributes(PropertyBuilder member, ReadOnlyCollection<AttributeAst> attributes, Parser parser, AttributeTargets attributeTargets)
 {
     if (attributes != null)
     {
         foreach (var attr in attributes)
         {
             var cabuilder = GetAttributeBuilder(parser, attr, attributeTargets);
             if (cabuilder != null)
             {
                 member.SetCustomAttribute(cabuilder);
             }
         }
     }
 }
开发者ID:40a,项目名称:PowerShell,代码行数:14,代码来源:PSType.cs

示例14: CreateAttribute

        //public virtual Descr  CreateAttribute()
        //{
        //}
        public CustomAttributeBuilder CreateAttribute(PropertyBuilder Property, Type Attribute, Type[] Parameters, Object[] Values)
        {
            ConstructorInfo attributeConstructor = Attribute.GetConstructor(Parameters);

            CustomAttributeBuilder newAttribute = new CustomAttributeBuilder(attributeConstructor,Values);

            Property.SetCustomAttribute(newAttribute);

            return newAttribute;
        }
开发者ID:MetalMynds,项目名称:FlatGlass,代码行数:13,代码来源:Strings.cs

示例15: HandleAlias

 public static void HandleAlias(ConverterInfo info, TypeInfo typeInfo, TypeDesc typeDesc, PropertyBuilder builder)
 {
     string aliasName = GetAliasName(info, typeInfo, typeDesc);
     if (aliasName != null)
         builder.SetCustomAttribute(CustomAttributeHelper.GetBuilderForComAliasName(aliasName));
 }
开发者ID:dbremner,项目名称:clrinterop,代码行数:6,代码来源:ConvCommon.cs


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