/// <summary>
 /// Generic method to find any type that has the specified attribute
 /// </summary>
 /// <typeparam name="TAttribute"></typeparam>
 /// <returns></returns>
 public IEnumerable <Type> ResolveAttributedTypes <TAttribute>(bool cacheResult = true, IEnumerable <Assembly> specificAssemblies = null)
     where TAttribute : Attribute
 {
     return(ResolveTypes <TAttribute>(
                () => TypeFinder.FindClassesWithAttribute <TAttribute>(specificAssemblies ?? AssembliesToScan),
                TypeResolutionKind.FindAttributedTypes,
                cacheResult));
 }
示例#2
0
 /// <summary>
 /// Generic method to find any type that has the specified attribute
 /// </summary>
 /// <typeparam name="TAttribute"></typeparam>
 /// <returns></returns>
 internal IEnumerable <Type> ResolveAttributedTypes <TAttribute>(bool cacheResult = true)
     where TAttribute : Attribute
 {
     return(ResolveTypes <TAttribute>(
                () => TypeFinder.FindClassesWithAttribute <TAttribute>(AssembliesToScan),
                TypeResolutionKind.FindAttributedTypes,
                cacheResult));
 }
        /// <summary>
        /// Resolves class types marked with the specified attribute.
        /// </summary>
        /// <typeparam name="TAttribute">The type of the attribute.</typeparam>
        /// <param name="cache">Indicates whether to use cache for type resolution.</param>
        /// <param name="specificAssemblies">A set of assemblies for type resolution.</param>
        /// <returns>All class types marked with the specified attribute.</returns>
        /// <remarks>Caching is disabled when using specific assemblies.</remarks>
        public IEnumerable <Type> ResolveAttributedTypes <TAttribute>(bool cache = true, IEnumerable <Assembly> specificAssemblies = null)
            where TAttribute : Attribute
        {
            // do not cache anything from specific assemblies
            cache &= specificAssemblies == null;

            return(ResolveTypesInternal(
                       typeof(object), typeof(TAttribute),
                       () => TypeFinder.FindClassesWithAttribute <TAttribute>(specificAssemblies ?? AssembliesToScan),
                       cache));
        }