コード例 #1
0
        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)));
        }
コード例 #2
0
        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());
        }
コード例 #4
0
        /// <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)));
        }