Пример #1
0
    /// <summary>
    /// Gets all the custom attributes for the given type.
    /// </summary>
    /// <param name="typeInfo">The type</param>
    /// <param name="attributeType">The type of the attribute</param>
    /// <returns>The matching attributes that decorate the type</returns>
    public static IEnumerable <_IAttributeInfo> GetCustomAttributes(this _ITypeInfo typeInfo, Type attributeType)
    {
        Guard.ArgumentNotNull(nameof(typeInfo), typeInfo);
        Guard.ArgumentNotNull(nameof(attributeType), attributeType);
        Guard.NotNull("Attribute type cannot be a generic type parameter", attributeType.AssemblyQualifiedName);

        return(typeInfo.GetCustomAttributes(attributeType.AssemblyQualifiedName));
    }
Пример #2
0
    /// <summary>
    /// Gets all the custom attributes for the given type.
    /// </summary>
    /// <param name="typeInfo">The type</param>
    /// <param name="attributeType">The type of the attribute</param>
    /// <returns>The matching attributes that decorate the type</returns>
    public static IReadOnlyCollection <_IAttributeInfo> GetCustomAttributes(this _ITypeInfo typeInfo, Type attributeType)
    {
        Guard.ArgumentNotNull(typeInfo);
        Guard.ArgumentNotNull(attributeType);
        Guard.NotNull("Attribute type cannot be a generic type parameter", attributeType.AssemblyQualifiedName);

        return(typeInfo.GetCustomAttributes(attributeType.AssemblyQualifiedName));
    }
Пример #3
0
        /// <inheritdoc/>
        public _ITestCollection Get(_ITypeInfo testClass)
        {
            Guard.ArgumentNotNull(nameof(testClass), testClass);

            var collectionAttribute = testClass.GetCustomAttributes(typeof(CollectionAttribute)).SingleOrDefault();

            if (collectionAttribute == null)
            {
                return(defaultCollection);
            }

            var collectionName = collectionAttribute.GetConstructorArguments().Cast <string>().Single();

            return(testCollections.GetOrAdd(collectionName, CreateTestCollection));
        }