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 : object
    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.

    This class caches the types it knows to avoid excessive assembly scanning and shorten startup times, relying on a hash of the DLLs in the ~/bin folder to check for cache expiration.

    Constructors

    View Source

    TypeLoader(ITypeFinder, IRuntimeHash, IAppPolicyCache, DirectoryInfo, ILogger<TypeLoader>, IProfiler, IEnumerable<Assembly>)

    Initializes a new instance of the TypeLoader class.

    Declaration
    public TypeLoader(ITypeFinder typeFinder, IRuntimeHash runtimeHash, IAppPolicyCache runtimeCache, DirectoryInfo localTempPath, ILogger<TypeLoader> logger, IProfiler profiler, IEnumerable<Assembly> assembliesToScan = null)
    Parameters
    Type Name Description
    ITypeFinder typeFinder
    IRuntimeHash runtimeHash
    IAppPolicyCache runtimeCache

    The application runtime cache.

    DirectoryInfo localTempPath

    Files storage location.

    ILogger<TypeLoader> logger

    A profiling logger.

    IProfiler profiler
    IEnumerable<Assembly> assembliesToScan
    View Source

    TypeLoader(ITypeFinder, IRuntimeHash, IAppPolicyCache, DirectoryInfo, ILogger<TypeLoader>, IProfiler, Boolean, IEnumerable<Assembly>)

    Initializes a new instance of the TypeLoader class.

    Declaration
    public TypeLoader(ITypeFinder typeFinder, IRuntimeHash runtimeHash, IAppPolicyCache runtimeCache, DirectoryInfo localTempPath, ILogger<TypeLoader> logger, IProfiler profiler, bool detectChanges, IEnumerable<Assembly> assembliesToScan = null)
    Parameters
    Type Name Description
    ITypeFinder typeFinder
    IRuntimeHash runtimeHash
    IAppPolicyCache runtimeCache

    The application runtime cache.

    DirectoryInfo localTempPath

    Files storage location.

    ILogger<TypeLoader> logger

    A profiling logger.

    IProfiler profiler
    System.Boolean detectChanges

    Whether to detect changes using hashes.

    IEnumerable<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<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

    AddTypeList(TypeLoader.TypeList)

    Sets a type list.

    Declaration
    public void AddTypeList(TypeLoader.TypeList typeList)
    Parameters
    Type Name Description
    TypeLoader.TypeList typeList
    Remarks

    For unit tests.

    View Source

    ClearTypesCache()

    Removes cache files and internal cache.

    Declaration
    public void ClearTypesCache()
    Remarks

    Generally only used for resetting cache, for example during the install process.

    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, 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.

    IEnumerable<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, 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.

    IEnumerable<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

    GetTypesListFilePath()

    Declaration
    public string GetTypesListFilePath()
    Returns
    Type Description
    System.String
    View Source

    GetTypesWithAttribute<T, TAttribute>(Boolean, 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.

    IEnumerable<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.

    View Source

    ReadCache()

    Declaration
    public Dictionary<(string, string), IEnumerable<string>> ReadCache()
    Returns
    Type Description
    Umbraco.Cms.Core.Dictionary<System.ValueTuple<System.String, System.String>, IEnumerable<System.String>>
    View Source

    TryGetCached(Type, Type)

    Declaration
    public Attempt<IEnumerable<string>> TryGetCached(Type baseType, Type attributeType)
    Parameters
    Type Name Description
    Type baseType
    Type attributeType
    Returns
    Type Description
    Attempt<IEnumerable<System.String>>
    View Source

    WriteCache()

    Declaration
    public void WriteCache()
    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • TypeLoader(ITypeFinder, IRuntimeHash, IAppPolicyCache, DirectoryInfo, ILogger<TypeLoader>, IProfiler, IEnumerable<Assembly>)
      • TypeLoader(ITypeFinder, IRuntimeHash, IAppPolicyCache, DirectoryInfo, ILogger<TypeLoader>, IProfiler, Boolean, IEnumerable<Assembly>)
    • Properties
      • AssembliesToScan
      • TypeFinder
      • TypeLists
    • Methods
      • AddTypeList(TypeLoader.TypeList)
      • ClearTypesCache()
      • GetAssemblyAttributes(Type[])
      • GetAttributedTypes<TAttribute>(Boolean, IEnumerable<Assembly>)
      • GetTypes<T>(Boolean, IEnumerable<Assembly>)
      • GetTypesListFilePath()
      • GetTypesWithAttribute<T, TAttribute>(Boolean, IEnumerable<Assembly>)
      • ReadCache()
      • TryGetCached(Type, Type)
      • WriteCache()
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX