internal static IEnumerable <_IAttributeInfo> GetCustomAttributes(
            Type type,
            string assemblyQualifiedAttributeTypeName)
        {
            var attributeType = ReflectionAttributeNameCache.GetType(assemblyQualifiedAttributeTypeName);

            Guard.ArgumentValidNotNull(nameof(assemblyQualifiedAttributeTypeName), $"Could not load type: '{assemblyQualifiedAttributeTypeName}'", attributeType);

            return(GetCustomAttributes(type, attributeType, GetAttributeUsage(attributeType)));
        }
        static IEnumerable <_IAttributeInfo> GetCustomAttributes(
            MethodInfo method,
            string assemblyQualifiedAttributeTypeName)
        {
            Guard.ArgumentNotNull(nameof(method), method);
            Guard.ArgumentNotNull(nameof(assemblyQualifiedAttributeTypeName), assemblyQualifiedAttributeTypeName);

            var attributeType = ReflectionAttributeNameCache.GetType(assemblyQualifiedAttributeTypeName);

            Guard.ArgumentValidNotNull(nameof(assemblyQualifiedAttributeTypeName), $"Could not load type: '{assemblyQualifiedAttributeTypeName}'", attributeType);

            return(GetCustomAttributes(method, attributeType, ReflectionAttributeInfo.GetAttributeUsage(attributeType)));
        }
示例#3
0
        /// <inheritdoc/>
        public IEnumerable <IAttributeInfo> GetCustomAttributes(string assemblyQualifiedAttributeTypeName)
        {
            var attributeType = ReflectionAttributeNameCache.GetType(assemblyQualifiedAttributeTypeName);

            Guard.ArgumentValid("assemblyQualifiedAttributeTypeName", "Could not locate type name", attributeType != null);

            return(Assembly.CustomAttributes
                   .Where(attr => attributeType.GetTypeInfo().IsAssignableFrom(attr.AttributeType.GetTypeInfo()))
                   .OrderBy(attr => attr.AttributeType.Name)
                   .Select(a => Reflector.Wrap(a))
                   .Cast <IAttributeInfo>()
                   .ToList());
        }
        /// <inheritdoc/>
        public IEnumerable <_IAttributeInfo> GetCustomAttributes(string assemblyQualifiedAttributeTypeName)
        {
            var attributeType = ReflectionAttributeNameCache.GetType(assemblyQualifiedAttributeTypeName);

            Guard.ArgumentValidNotNull(nameof(assemblyQualifiedAttributeTypeName), $"Could not load type: '{assemblyQualifiedAttributeTypeName}'", attributeType);

            return
                (Assembly
                 .CustomAttributes
                 .Where(attr => attributeType.IsAssignableFrom(attr.AttributeType))
                 .OrderBy(attr => attr.AttributeType.Name)
                 .Select(a => Reflector.Wrap(a))
                 .Cast <_IAttributeInfo>()
                 .ToList());
        }
示例#5
0
        /// <inheritdoc/>
        public IReadOnlyCollection <_IAttributeInfo> GetCustomAttributes(string assemblyQualifiedAttributeTypeName)
        {
            var attributeType = ReflectionAttributeNameCache.GetType(assemblyQualifiedAttributeTypeName);

            Guard.ArgumentNotNull($"Could not load type: '{assemblyQualifiedAttributeTypeName}'", attributeType, nameof(assemblyQualifiedAttributeTypeName));

            return
                (additionalAssemblyAttributes
                 .Where(customAttribute => attributeType.IsAssignableFrom(customAttribute.Attribute.GetType()))
                 .Concat(
                     Assembly
                     .CustomAttributes
                     .Where(attr => attributeType.IsAssignableFrom(attr.AttributeType))
                     .OrderBy(attr => attr.AttributeType.Name)
                     .Select(a => Reflector.Wrap(a))
                     .Cast <_IAttributeInfo>()
                     )
                 .CastOrToReadOnlyCollection());
        }
示例#6
0
        internal static IEnumerable <IAttributeInfo> GetCustomAttributes(Type type, string assemblyQualifiedAttributeTypeName)
        {
            Type attributeType = ReflectionAttributeNameCache.GetType(assemblyQualifiedAttributeTypeName);

            return(GetCustomAttributes(type, attributeType, GetAttributeUsage(attributeType)));
        }
示例#7
0
        static IEnumerable <IAttributeInfo> GetCustomAttributes(MethodInfo method, string assemblyQualifiedAttributeTypeName)
        {
            var attributeType = ReflectionAttributeNameCache.GetType(assemblyQualifiedAttributeTypeName);

            return(GetCustomAttributes(method, attributeType, ReflectionAttributeInfo.GetAttributeUsage(attributeType)));
        }