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


C# ICustomAttributeProvider.GetAttributes方法代码示例

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


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

示例1: GetAttributes

 public IEnumerable<ValidationAttribute> GetAttributes(ICustomAttributeProvider attributeProvider)
 {
     return attributeProvider
         .GetAttributes<ValidationAttribute>()
         .Select(attr => container.BuildUp(attr.GetType(), attr))
         .Cast<ValidationAttribute>();
 }
开发者ID:tmont,项目名称:portoa,代码行数:7,代码来源:BuildUpAttributeProvider.cs

示例2: CreateMetaData

        /// <summary>
        /// Create all meta-data elements
        /// </summary>
        private void CreateMetaData(XElement parent, ICustomAttributeProvider provider)
        {
            // Create meta-data elements
            foreach (var attr in provider.GetAttributes(MetaDataAttribute))
            {
                var metaData = new XElement("meta-data");
                parent.Add(metaData);

                metaData.AddAttrIfNotEmpty("name", Namespace, attr.GetValue<string>(-1, "Name"));
                metaData.AddAttrIfNotEmpty("value", Namespace, attr.GetValue<string>(-1, "Value"));
                metaData.AddAttrIfNotEmpty("resource", Namespace, attr.GetValue<string>(-1, "Resource"), x => FormatResourceId(x, ResourceType.Unknown));
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:16,代码来源:MetaData.cs

示例3: GetAttributedImport

        private static IAttributedImport GetAttributedImport(ReflectionItem item, ICustomAttributeProvider attributeProvider)
        {
            IAttributedImport[] imports = attributeProvider.GetAttributes<IAttributedImport>(false);

            // For constructor parameters they may not have an ImportAttribute
            if (imports.Length == 0)
            {
                return new ImportAttribute();
            }

            if (imports.Length > 1)
            {
                CompositionTrace.MemberMarkedWithMultipleImportAndImportMany(item);
            }

            // Regardless of how many imports, always return the first one
            return imports[0];
        }
开发者ID:nlhepler,项目名称:mono,代码行数:18,代码来源:AttributedModelDiscovery.cs

示例4: GetAttributedImport

        private static IAttributedImport GetAttributedImport(ReflectionItem item, ICustomAttributeProvider attributeProvider)
        {
            IAttributedImport[] imports = attributeProvider.GetAttributes<IAttributedImport>(false);

            // For constructor parameters they may not have an ImportAttribute
            if (imports.Length == 0)
            {
                return new ImportAttribute();
            }

            if (imports.Length == 1)
            {
                return imports[0];
            }

            // DiscoveryError (Dev10:602872): This should go through the discovery error reporting when
            // we add a way to report discovery errors properly.
            throw ExceptionBuilder.CreateDiscoveryException(Strings.Discovery_MultipleImportAttributes, item.GetDisplayName());
        }
开发者ID:lucaslra,项目名称:SPM,代码行数:19,代码来源:AttributedModelDiscovery.cs

示例5: GetAttributes

 public IEnumerable<ValidationAttribute> GetAttributes(ICustomAttributeProvider attributeProvider)
 {
     return attributeProvider.GetAttributes<ValidationAttribute>();
 }
开发者ID:tmont,项目名称:portoa,代码行数:4,代码来源:ReflectionValidationAttributeProvider.cs


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