Wolfringo Wolfringo
Wolfringo Wolfringo
Wolfringo (c) 2020 TehGM
DocFX, DiscordFX theme.
Search Results for

    Class CommandsLoader

    A service that loads Command instance descriptors from types and assemblies.

    Inheritance
    System.Object
    CommandsLoader
    Implements
    ICommandsLoader
    Namespace: TehGM.Wolfringo.Commands.Initialization
    Assembly: Wolfringo.Commands.dll
    Syntax
    public class CommandsLoader : ICommandsLoader

    Constructors

    | Improve this Doc View Source

    CommandsLoader(ICommandInitializerProvider, ILogger)

    Creates a new loader instance.

    Declaration
    public CommandsLoader(ICommandInitializerProvider initializers, ILogger log = null)
    Parameters
    Type Name Description
    ICommandInitializerProvider initializers

    Command initializers mapping.

    Microsoft.Extensions.Logging.ILogger log

    Logger to log messages and errors to. If null, all logging will be disabled.

    | Improve this Doc View Source

    CommandsLoader(ICommandInitializerProvider, ILogger<CommandsLoader>)

    Creates a new loader instance.

    Declaration
    public CommandsLoader(ICommandInitializerProvider initializers, ILogger<CommandsLoader> log)
    Parameters
    Type Name Description
    ICommandInitializerProvider initializers

    Command initializers mapping.

    Microsoft.Extensions.Logging.ILogger<CommandsLoader> log

    Logger to log messages and errors to. If null, all logging will be disabled.

    Methods

    | Improve this Doc View Source

    LoadFromAssemblyAsync(Assembly, CancellationToken)

    Loads all command instance descriptors from an assembly.

    Declaration
    public Task<IEnumerable<ICommandInstanceDescriptor>> LoadFromAssemblyAsync(Assembly assembly, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.Reflection.Assembly assembly

    Assembly to load descriptors from.

    System.Threading.CancellationToken cancellationToken

    Token that can be used to stop loading.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ICommandInstanceDescriptor>>

    Enumerable of all loaded command descriptors.

    Remarks

    Only commands from types marked with CommandsHandlerAttribute will be loaded.

    | Improve this Doc View Source

    LoadFromMethodAsync(MethodInfo, CancellationToken)

    Loads all command instance descriptors from a method.

    Declaration
    public Task<IEnumerable<ICommandInstanceDescriptor>> LoadFromMethodAsync(MethodInfo method, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.Reflection.MethodInfo method

    Method to load descriptors from.

    System.Threading.CancellationToken cancellationToken

    Token that can be used to stop loading.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ICommandInstanceDescriptor>>

    Enumerable of all loaded command descriptors.

    Remarks

    Commands will be loaded regardless of presence of CommandsHandlerAttribute.

    Exceptions
    Type Condition
    System.InvalidOperationException

    No mapped initializer for a command was found.

    | Improve this Doc View Source

    LoadFromTypeAsync(TypeInfo, CancellationToken)

    Loads all command instance descriptors from a type.

    Declaration
    public Task<IEnumerable<ICommandInstanceDescriptor>> LoadFromTypeAsync(TypeInfo type, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.Reflection.TypeInfo type

    Type to load descriptors from.

    System.Threading.CancellationToken cancellationToken

    Token that can be used to stop loading.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ICommandInstanceDescriptor>>

    Enumerable of all loaded command descriptors.

    Remarks

    Commands will be loaded regardless of presence of CommandsHandlerAttribute.

    Implements

    ICommandsLoader

    Extension Methods

    CommandsLoaderExtensions.LoadFromAssembliesAsync(ICommandsLoader, IEnumerable<Assembly>, CancellationToken)
    CommandsLoaderExtensions.LoadFromTypesAsync(ICommandsLoader, IEnumerable<TypeInfo>, CancellationToken)
    CommandsLoaderExtensions.LoadFromMethodsAsync(ICommandsLoader, IEnumerable<MethodInfo>, CancellationToken)