示例#1
0
 public static ICollection <string> GetTags(this IMetadataEntity type)
 {
     return(type.AndAllBaseTypes()
            .SelectMany(x => x.GetCustomAttributes(typeof(TagsAttribute).FullName))
            .Select(x => x.ConstructorArguments)
            .Flatten(tag => tag.FirstOrDefault().Value as string,
                     tag => tag.Skip(1).FirstOrDefault().ValuesArray.Select(v => v.Value as string))
            .Distinct()
            .ToList());
 }
        private static IList <IMetadataCustomAttribute> GetSubjectAttributes(IMetadataEntity metadataEntity, SubjectAttributeFullName subjectAttributeFullName)
        {
            var derivedAndBaseTypes = metadataEntity.AndAllBaseTypes();

            foreach (var type in derivedAndBaseTypes)
            {
                var attributes = type.CustomAttributes.ToList().Where(x => x.GetCustomAttributes(subjectAttributeFullName) != null);
                if (attributes.Any())
                {
                    return(attributes.ToList());
                }
            }

            return(new List <IMetadataCustomAttribute>());
        }
 private static IList <IMetadataCustomAttribute> GetSubjectAttributes(IMetadataEntity metadataEntity)
 {
     return(metadataEntity.AndAllBaseTypes()
            .SelectMany(x => x.GetCustomAttributes(FullNames.SubjectAttribute))
            .ToList());
 }