Search Results for

    Show / Hide Table of Contents
    View Source

    Class TypeLoader

    Provides methods to find and instantiate types.

    Inheritance
    System.Object
    Namespace: Umbraco.Cms.Core.Composing
    Assembly: Umbraco.Core.dll
    Syntax
    public sealed class TypeLoader
    Remarks

    This class should be used to get all types, the ITypeFinder class should never be used directly.

    In most cases this class is not used directly but through extension methods that retrieve specific types.

    Constructors

    View Source

    TypeLoader(ITypeFinder, ILogger<TypeLoader>, Nullable<IEnumerable<Assembly>>)

    Declaration
    public TypeLoader(ITypeFinder typeFinder, ILogger<TypeLoader> logger, IEnumerable<Assembly>? assembliesToScan = null)
    Parameters
    Type Name Description
    ITypeFinder typeFinder
    ILogger<TypeLoader> logger
    System.Nullable<IEnumerable<System.Reflection.Assembly>> assembliesToScan

    Properties

    View Source

    AssembliesToScan

    Gets or sets the set of assemblies to scan.

    Declaration
    public IEnumerable<Assembly> AssembliesToScan { get; }
    Property Value
    Type Description
    IEnumerable<System.Reflection.Assembly>
    Remarks

    If not explicitly set, defaults to all assemblies except those that are know to not have any of the types we might scan. Because we only scan for application types, this means we can safely exclude GAC assemblies for example.

    This is for unit tests.

    View Source

    TypeFinder

    Returns the underlying ITypeFinder

    Declaration
    public ITypeFinder TypeFinder { get; }
    Property Value
    Type Description
    ITypeFinder
    View Source

    TypeLists

    Gets the type lists.

    Declaration
    public IEnumerable<TypeLoader.TypeList> TypeLists { get; }
    Property Value
    Type Description
    IEnumerable<TypeLoader.TypeList>
    Remarks

    For unit tests.

    Methods

    View Source

    GetAssemblyAttributes(Type[])

    Gets the assembly attributes of the specified attributeTypes.

    Declaration
    public IEnumerable<Attribute> GetAssemblyAttributes(params Type[] attributeTypes)
    Parameters
    Type Name Description
    Type[] attributeTypes

    The attribute types.

    Returns
    Type Description
    IEnumerable<Attribute>

    The assembly attributes of the specified types.

    View Source

    GetAttributedTypes<TAttribute>(Boolean, Nullable<IEnumerable<Assembly>>)

    Gets class types marked with the specified attribute.

    Declaration
    public IEnumerable<Type> GetAttributedTypes<TAttribute>(bool cache = true, IEnumerable<Assembly>? specificAssemblies = null)
        where TAttribute : Attribute
    Parameters
    Type Name Description
    System.Boolean cache

    Indicates whether to use cache for type resolution.

    System.Nullable<IEnumerable<System.Reflection.Assembly>> specificAssemblies

    A set of assemblies for type resolution.

    Returns
    Type Description
    IEnumerable<Type>

    All class types marked with the specified attribute.

    Type Parameters
    Name Description
    TAttribute

    The type of the attribute.

    Remarks

    Caching is disabled when using specific assemblies.

    View Source

    GetTypes<T>(Boolean, Nullable<IEnumerable<Assembly>>)

    Gets class types inheriting from or implementing the specified type

    Declaration
    public IEnumerable<Type> GetTypes<T>(bool cache = true, IEnumerable<Assembly>? specificAssemblies = null)
    Parameters
    Type Name Description
    System.Boolean cache

    Indicates whether to use cache for type resolution.

    System.Nullable<IEnumerable<System.Reflection.Assembly>> specificAssemblies

    A set of assemblies for type resolution.

    Returns
    Type Description
    IEnumerable<Type>

    All class types inheriting from or implementing the specified type.

    Type Parameters
    Name Description
    T

    The type to inherit from or implement.

    Remarks

    Caching is disabled when using specific assemblies.

    View Source

    GetTypesWithAttribute<T, TAttribute>(Boolean, Nullable<IEnumerable<Assembly>>)

    Gets class types inheriting from or implementing the specified type and marked with the specified attribute.

    Declaration
    public IEnumerable<Type> GetTypesWithAttribute<T, TAttribute>(bool cache = true, IEnumerable<Assembly>? specificAssemblies = null)
        where TAttribute : Attribute
    Parameters
    Type Name Description
    System.Boolean cache

    Indicates whether to use cache for type resolution.

    System.Nullable<IEnumerable<System.Reflection.Assembly>> specificAssemblies

    A set of assemblies for type resolution.

    Returns
    Type Description
    IEnumerable<Type>

    All class types inheriting from or implementing the specified type and marked with the specified attribute.

    Type Parameters
    Name Description
    T

    The type to inherit from or implement.

    TAttribute

    The type of the attribute.

    Remarks

    Caching is disabled when using specific assemblies.

    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • TypeLoader(ITypeFinder, ILogger<TypeLoader>, Nullable<IEnumerable<Assembly>>)
    • Properties
      • AssembliesToScan
      • TypeFinder
      • TypeLists
    • Methods
      • GetAssemblyAttributes(Type[])
      • GetAttributedTypes<TAttribute>(Boolean, Nullable<IEnumerable<Assembly>>)
      • GetTypes<T>(Boolean, Nullable<IEnumerable<Assembly>>)
      • GetTypesWithAttribute<T, TAttribute>(Boolean, Nullable<IEnumerable<Assembly>>)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX