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


C# ICustomAttributeProvider.GetCustomAttributes方法代码示例

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


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

示例1: MakeNode

 private static DashbardIconWithDisplay MakeNode(DashboardIconAttribute sitemapNodeAttr, ICustomAttributeProvider info)
 {
     var sitemapNode = new DashbardIconWithDisplay
     {
         DashboardIcon = sitemapNodeAttr,
         Display = info.GetCustomAttributes(false).OfType<DisplayAttribute>().FirstOrDefault(),
         Url = info.GetCustomAttributes(false).OfType<IUrl>().FirstOrDefault() ?? new ConstUrl("#")
     };
     return sitemapNode;
 }
开发者ID:yangwen27,项目名称:moonlit,代码行数:10,代码来源:ReflectionDashboardIconLoader.cs

示例2: TemplateBuilder

		internal TemplateBuilder (ICustomAttributeProvider prov)
		{
			object[] ats = prov.GetCustomAttributes (typeof (TemplateContainerAttribute), true);
			if (ats.Length > 0)
				containerAttribute = (TemplateContainerAttribute) ats [0];

			ats = prov.GetCustomAttributes (typeof (TemplateInstanceAttribute), true);
			if (ats.Length > 0)
				instanceAttribute = (TemplateInstanceAttribute) ats [0];
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:TemplateBuilder.cs

示例3: BuildInitializedMember

        private static void BuildInitializedMember(List<InitializedMember> members, ICustomAttributeProvider attributeProvider, InitializedMemberFactory factory)
        {
            var finders = (ComponentFinderAttribute[]) attributeProvider.GetCustomAttributes(typeof(ComponentFinderAttribute), true);
            if (finders.Length == 0)
                return;
            if (finders.Length > 1)
                throw new InvalidOperationException(string.Format("Member '{0}' has more than one ComponentFinderAttribute.", attributeProvider));

            var finder = finders[0];
            var decorators = (ComponentDecoratorAttribute[])attributeProvider.GetCustomAttributes(typeof(ComponentDecoratorAttribute), true);

            InitializedMember member = factory(finder, decorators);
            members.Add(member);
        }
开发者ID:kumichou,项目名称:WatiN_FindByCssSelector,代码行数:14,代码来源:Composite.cs

示例4: Draw3

 public static ReferenceType<Boolean3> Draw3(Rect position, object eventsObj, GUIContent content, ICustomAttributeProvider info = null)
 {
     Boolean3 boolPair = (Boolean3)eventsObj;
     var boolArray = new bool[] { boolPair.x, boolPair.y, boolPair.z };
     Builder = new StringBuilder();
     char flags = (char)EditorNameFlags.Default;
     if (info != null && info.HasAttribute(typeof(CustomNamesAttribute)))
     {
         CustomNamesAttribute attribute = info.GetCustomAttributes<CustomNamesAttribute>()[0];
         flags = (char)attribute.CustomFlags;
         Builder.Append(flags);
         if (attribute.UseVariableNameAsTitle)
         {
             Builder.Append(Seperator);
             Builder.Append(content.text);
         }
         Builder.Append(attribute.CombinedName);
     }
     else
     {
         Builder.Append(flags);
         Builder.Append(Seperator);
         Builder.Append(content.text);
     }
     content.text = Builder.ToString();
     DrawMultiBoolean(ref boolArray, position, content);
     boolPair.x = boolArray[0];
     boolPair.y = boolArray[1];
     boolPair.z = boolArray[2];
     return boolPair;
 }
开发者ID:Filiecs,项目名称:U-EAT,代码行数:31,代码来源:Boolean3.cs

示例5: GetBinderFromAttributes

        internal static IModelBinder GetBinderFromAttributes(ICustomAttributeProvider element, Func<string> errorMessageAccessor)
        {
            // this method is used to get a custom binder based on the attributes of the element passed to it.
            // it will return null if a binder cannot be detected based on the attributes alone.

            var attrs = (CustomModelBinderAttribute[]) element.GetCustomAttributes(typeof (CustomModelBinderAttribute), true /* inherit */);
            if (attrs == null)
            {
                return null;
            }

            switch (attrs.Length)
            {
                case 0:
                    return null;

                case 1:
                    var binder = attrs[0].GetBinder();
                    return binder;

                default:
                    var errorMessage = errorMessageAccessor();
                    throw new InvalidOperationException(errorMessage);
            }
        }
开发者ID:jdhardy,项目名称:ironrubymvc,代码行数:25,代码来源:RubyModelBinders.cs

示例6: SoapAttributes

 /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapAttributes(ICustomAttributeProvider provider) {
     object[] attrs = provider.GetCustomAttributes(false);
     for (int i = 0; i < attrs.Length; i++) {
         if (attrs[i] is SoapIgnoreAttribute || attrs[i] is ObsoleteAttribute) {
             this.soapIgnore = true;
             break;
         }
         else if (attrs[i] is SoapElementAttribute) {
             this.soapElement = (SoapElementAttribute)attrs[i];
         }
         else if (attrs[i] is SoapAttributeAttribute) {
             this.soapAttribute = (SoapAttributeAttribute)attrs[i];
         }
         else if (attrs[i] is SoapTypeAttribute) {
             this.soapType = (SoapTypeAttribute)attrs[i];
         }
         else if (attrs[i] is SoapEnumAttribute) {
             this.soapEnum = (SoapEnumAttribute)attrs[i];
         }
         else if (attrs[i] is DefaultValueAttribute) {
             this.soapDefaultValue = ((DefaultValueAttribute)attrs[i]).Value;
         }
     }
     if (soapIgnore) {
         this.soapElement = null;
         this.soapAttribute = null;
         this.soapType = null;
         this.soapEnum = null;
         this.soapDefaultValue = null;
     }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:35,代码来源:soapattributes.cs

示例7: IncludeTypes

 private void IncludeTypes(ICustomAttributeProvider provider, RecursionLimiter limiter)
 {
     object[] attrs = provider.GetCustomAttributes(typeof(SoapIncludeAttribute), false);
     for (int i = 0; i < attrs.Length; i++) {
         IncludeType(((SoapIncludeAttribute)attrs[i]).Type, limiter);
     }
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:7,代码来源:SoapReflectionImporter.cs

示例8: XmlAttributes

		public XmlAttributes (ICustomAttributeProvider provider)
		{
			object[] attributes = provider.GetCustomAttributes(false);
			foreach(object obj in attributes)
			{
				if(obj is XmlAnyAttributeAttribute)
					xmlAnyAttribute = (XmlAnyAttributeAttribute) obj;
				else if(obj is XmlAnyElementAttribute)
					xmlAnyElements.Add((XmlAnyElementAttribute) obj);
				else if(obj is XmlArrayAttribute)
					xmlArray = (XmlArrayAttribute) obj;
				else if(obj is XmlArrayItemAttribute)
					xmlArrayItems.Add((XmlArrayItemAttribute) obj);
				else if(obj is XmlAttributeAttribute)
					xmlAttribute = (XmlAttributeAttribute) obj;
				else if(obj is XmlChoiceIdentifierAttribute)
					xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute) obj;
				else if(obj is DefaultValueAttribute)
					xmlDefaultValue = ((DefaultValueAttribute)obj).Value;
				else if(obj is XmlElementAttribute )
					xmlElements.Add((XmlElementAttribute ) obj);
				else if(obj is XmlEnumAttribute)
					xmlEnum = (XmlEnumAttribute) obj;
				else if(obj is XmlIgnoreAttribute)
					xmlIgnore = true;
				else if(obj is XmlNamespaceDeclarationsAttribute)
					xmlns = true;
				else if(obj is XmlRootAttribute)
					xmlRoot = (XmlRootAttribute) obj;
				else if(obj is XmlTextAttribute)
					xmlText = (XmlTextAttribute) obj;
				else if(obj is XmlTypeAttribute)
					xmlType = (XmlTypeAttribute) obj;
			}
		}
开发者ID:wamiq,项目名称:debian-mono,代码行数:35,代码来源:XmlAttributes.cs

示例9: GetInvalidSuppressMessageAttributeErrorsCore

 private static IEnumerable<string> GetInvalidSuppressMessageAttributeErrorsCore(ICustomAttributeProvider target, string name, string targetType, IEnumerable<Exemption> exemptions) {
     foreach (SuppressMessageAttribute attr in target.GetCustomAttributes(typeof(SuppressMessageAttribute), false).OfType<SuppressMessageAttribute>()) {
         if (String.IsNullOrWhiteSpace(attr.Justification) && !IsExempt(exemptions, attr.CheckId, name, targetType)) {
             yield return FormatErrorMessage(attr, name, targetType);
         }
     }
 }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:7,代码来源:SuppressMessageUtil.cs

示例10: FromCustomAttributeProvider

        public static IEnumerable<UsesFeatureAttribute> FromCustomAttributeProvider(ICustomAttributeProvider provider)
        {
            var attrs = provider.GetCustomAttributes ("Android.App.UsesFeatureAttribute");
            foreach (var attr in attrs) {

                UsesFeatureAttribute self = new UsesFeatureAttribute ();

                if (attr.HasProperties) {
                    // handle the case where the user sets additional properties
                    self.specified = mapping.Load (self, attr);
                    if (self.specified.Contains("GLESVersion") && self.GLESVersion==0) {
                        throw new InvalidOperationException("Invalid value '0' for UsesFeatureAttribute.GLESVersion.");
                    }
                }
                if (attr.HasConstructorArguments) {
                    // in this case the user used one of the Consructors to pass arguments and possibly properties
                    // so we only create the specified list if its not been created already
                    if (self.specified == null)
                        self.specified = new List<string>();
                    foreach(var arg in attr.ConstructorArguments) {
                        if (arg.Value.GetType() == typeof(string)) {
                            self.specified.Add("Name");
                            self.Name = (string)arg.Value;
                        }
                    }
                }
                yield return self;
            }
        }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:29,代码来源:UsesFeatureAttribute.Partial.cs

示例11: FromCustomAttributeProvider

        public static IEnumerable<UsesLibraryAttribute> FromCustomAttributeProvider(ICustomAttributeProvider provider)
        {
            var attrs = provider.GetCustomAttributes ("Android.App.UsesLibraryAttribute");
            foreach (var attr in attrs) {
                UsesLibraryAttribute self;

                string[] extra = null;
                if (attr.ConstructorArguments.Count == 1) {
                    self = new UsesLibraryAttribute (
                            (string)  attr.ConstructorArguments [0].Value);
                    extra = new[]{"Name"};
                } else if (attr.ConstructorArguments.Count == 2) {
                    self = new UsesLibraryAttribute (
                            (string)  attr.ConstructorArguments [0].Value,
                            (bool)    attr.ConstructorArguments [1].Value);
                    extra = new[]{"Name", "Required"};
                } else {
                    self = new UsesLibraryAttribute ();
                    extra = new string[0];
                }

                self.specified = mapping.Load (self, attr);

                foreach (var e in extra)
                    self.specified.Add (e);

                yield return self;
            }
        }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:29,代码来源:UsesLibraryAttribute.Partial.cs

示例12: GetDescrition

 internal static string GetDescrition(MemberInfo member, ICustomAttributeProvider provider, string defaultValue, string memberSuffix)
 {
     Type t = member as Type;
      if (t == null)
      {
     t = member.DeclaringType;
      }
      object[] attributes = t.GetCustomAttributes(typeof(MBeanResourceAttribute), true);
      if (attributes.Length > 0)
      {
     ResourceManager manager = new ResourceManager(((MBeanResourceAttribute)attributes[0]).ResourceName, t.Assembly);
     string name = memberSuffix == null ? member.Name : member.Name + "__" + memberSuffix;
     string descr = manager.GetString(member.Name);
     if (descr != null)
     {
        return descr;
     }
      }
      attributes = provider.GetCustomAttributes(typeof(DescriptionAttribute), true);
      if (attributes.Length > 0)
      {
     return ((DescriptionAttribute)attributes[0]).Description;
      }
      return defaultValue;
 }
开发者ID:SzymonPobiega,项目名称:NetMX,代码行数:25,代码来源:InfoUtils.cs

示例13: AttributeSet

 public AttributeSet(ICustomAttributeProvider attributeProvider)
 {
     this.attributes = attributeProvider
         .GetCustomAttributes(true)
         .Cast<Attribute>()
         .ToArray();
 }
开发者ID:MatanShahar,项目名称:IntelliSun,代码行数:7,代码来源:AttributeSet.cs

示例14: GetTypeConverters

 public static ITypeConverter[] GetTypeConverters(ICustomAttributeProvider attributeProvider)
 {
     var attributes = attributeProvider.GetCustomAttributes(typeof(TypeConverterAttribute), true).Cast<TypeConverterAttribute>();
     return attributes
         .Select(x => new { x.Context, Converter = (ITypeConverter)Activator.CreateInstance(x.ConverterType) })
         .Select(x => x.Context == TypeConversionContext.None ? x.Converter : new ContextBasedTypeConverter(x.Context, x.Converter))
         .ToArray();
 }
开发者ID:kswoll,项目名称:sexy-http,代码行数:8,代码来源:TypeConverterAttribute.cs

示例15: GetHeaders

 public static HttpHeader[] GetHeaders(ICustomAttributeProvider provider)
 {
     return provider
         .GetCustomAttributes(typeof(HeaderAttribute), true)
         .Cast<HeaderAttribute>()
         .Select(x => new HttpHeader(x.Name, x.Values))
         .ToArray();
 }
开发者ID:kswoll,项目名称:sexy-http,代码行数:8,代码来源:HeaderAttribute.cs


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