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
    View Source

    TypeLoader(ITypeFinder, IRuntimeHash, IAppPolicyCache, DirectoryInfo, ILogger<TypeLoader>, IProfiler, Boolean, Nullable<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
    DirectoryInfo localTempPath
    ILogger<TypeLoader> logger
    IProfiler profiler
    System.Boolean detectChanges
    System.Nullable<IEnumerable<System.Reflection.Assembly>> assembliesToScan
    View Source

    TypeLoader(ITypeFinder, IRuntimeHash, IAppPolicyCache, DirectoryInfo, ILogger<TypeLoader>, IProfiler, Nullable<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
    DirectoryInfo localTempPath
    ILogger<TypeLoader> logger
    IProfiler profiler
    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

    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()

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

    GetTypesListFilePath()

    Declaration
    public string GetTypesListFilePath()
    Returns
    Type Description
    System.String
    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.

    View Source

    ReadCache()

    Declaration
    public Dictionary<(string, string), IEnumerable<string>>? ReadCache()
    Returns
    Type Description
    System.Nullable<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, ILogger<TypeLoader>, Nullable<IEnumerable<Assembly>>)
      • TypeLoader(ITypeFinder, IRuntimeHash, IAppPolicyCache, DirectoryInfo, ILogger<TypeLoader>, IProfiler, Boolean, Nullable<IEnumerable<Assembly>>)
      • TypeLoader(ITypeFinder, IRuntimeHash, IAppPolicyCache, DirectoryInfo, ILogger<TypeLoader>, IProfiler, Nullable<IEnumerable<Assembly>>)
    • Properties
      • AssembliesToScan
      • TypeFinder
      • TypeLists
    • Methods
      • AddTypeList(TypeLoader.TypeList)
      • ClearTypesCache()
      • GetAssemblyAttributes(Type[])
      • GetAttributedTypes<TAttribute>(Boolean, Nullable<IEnumerable<Assembly>>)
      • GetTypes<T>(Boolean, Nullable<IEnumerable<Assembly>>)
      • GetTypesListFilePath()
      • GetTypesWithAttribute<T, TAttribute>(Boolean, Nullable<IEnumerable<Assembly>>)
      • ReadCache()
      • TryGetCached(Type, Type)
      • WriteCache()
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX