本文整理汇总了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>();
}
示例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));
}
}
示例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];
}
示例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());
}
示例5: GetAttributes
public IEnumerable<ValidationAttribute> GetAttributes(ICustomAttributeProvider attributeProvider)
{
return attributeProvider.GetAttributes<ValidationAttribute>();
}