Table of Contents

Class ITerminalBuilderExtensions

Namespace
OneImlx.Terminal.Extensions
Assembly
OneImlx.Terminal.dll

The ITerminalBuilder extension methods.

public static class ITerminalBuilderExtensions
Inheritance
ITerminalBuilderExtensions
Inherited Members

Methods

AddArgumentChecker<TMapper, TChecker>(ITerminalBuilder)

Adds the IDataTypeMapper<TValue> and IArgumentChecker to the service collection.

public static ITerminalBuilder AddArgumentChecker<TMapper, TChecker>(this ITerminalBuilder builder) where TMapper : class, IDataTypeMapper<Argument> where TChecker : class, IArgumentChecker

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TMapper

The argument mapper type.

TChecker

The argument checker type.

AddCommandParser<TCommand, TRequest>(ITerminalBuilder)

Adds the ICommandParser to the service collection.

public static ITerminalBuilder AddCommandParser<TCommand, TRequest>(this ITerminalBuilder builder) where TCommand : class, ICommandParser where TRequest : class, ITerminalRequestParser

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TCommand

The command parser type.

TRequest

The terminal request parser type.

AddCommandRouter<TRouter, THandler, TResolver>(ITerminalBuilder)

Adds the ICommandRouter and ICommandHandler to the service collection.

public static ITerminalBuilder AddCommandRouter<TRouter, THandler, TResolver>(this ITerminalBuilder builder) where TRouter : class, ICommandRouter where THandler : class, ICommandHandler where TResolver : class, ICommandResolver

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TRouter
THandler
TResolver

AddCommandStore<TStore>(ITerminalBuilder)

Adds the ITerminalCommandStore to the service collection.

public static ITerminalBuilder AddCommandStore<TStore>(this ITerminalBuilder builder) where TStore : class, ITerminalCommandStore

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TStore

The command descriptor store type.

AddConfigurationOptions(ITerminalBuilder)

Adds the TerminalOptions to the service collection.

public static ITerminalBuilder AddConfigurationOptions(this ITerminalBuilder builder)

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

AddConsole<TConsole>(ITerminalBuilder)

Adds the ITerminalConsole to the service collection.

public static ITerminalBuilder AddConsole<TConsole>(this ITerminalBuilder builder) where TConsole : class, ITerminalConsole

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TConsole

AddDeclarativeAssembly(ITerminalBuilder, Assembly)

Adds all the IDeclarativeRunner implementations to the service collection.

public static ITerminalBuilder AddDeclarativeAssembly(this ITerminalBuilder builder, Assembly assembly)

Parameters

builder ITerminalBuilder

The builder.

assembly Assembly

The assembly to inspect.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Remarks

The AddDeclarativeAssembly(ITerminalBuilder, Assembly) reads the target assembly and inspects all the declarative targets using reflection. Reflection may have a performance bottleneck. For more optimized and direct declarative target inspection, use AddDeclarativeRunner<TDeclarativeRunner>(ITerminalBuilder).

AddDeclarativeAssembly(ITerminalBuilder, Type)

Adds all the IDeclarativeRunner implementations to the service collection.

public static ITerminalBuilder AddDeclarativeAssembly(this ITerminalBuilder builder, Type assemblyType)

Parameters

builder ITerminalBuilder

The builder.

assemblyType Type

The type whose assembly to inspect and read all the declarative targets.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Remarks

The AddDeclarativeAssembly(ITerminalBuilder, Type) reads the target assembly and inspects all the declarative targets using reflection. Reflection may have a performance bottleneck. For more optimized and direct declarative target inspection, use AddDeclarativeRunner<TDeclarativeRunner>(ITerminalBuilder).

AddDeclarativeAssembly<TType>(ITerminalBuilder)

Adds all the IDeclarativeRunner implementations to the service collection.

public static ITerminalBuilder AddDeclarativeAssembly<TType>(this ITerminalBuilder builder)

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TType

The type whose assembly to inspect and read all the declarative targets.

Remarks

The AddDeclarativeAssembly(ITerminalBuilder, Type) reads the target assembly and inspects all the declarative targets using reflection. Reflection may have a performance bottleneck. For more optimized and direct declarative target inspection, use AddDeclarativeRunner<TDeclarativeRunner>(ITerminalBuilder).

AddDeclarativeRunner<TDeclarativeRunner>(ITerminalBuilder)

Adds a IDeclarativeRunner to the service collection.

public static ITerminalBuilder AddDeclarativeRunner<TDeclarativeRunner>(this ITerminalBuilder builder) where TDeclarativeRunner : IDeclarativeRunner

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The AddDeclarativeRunner<TDeclarativeRunner>(ITerminalBuilder) inspects the declarative target type using reflection.

Type Parameters

TDeclarativeRunner

AddDynamics<TContext, TSource, TChecker, TLoader>(ITerminalBuilder)

Adds dynamics services to the terminal builder for loading commands from an external source. This method registers the specified command source, command source checker, and command source assembly loader as singletons in the service collection.

public static ITerminalBuilder AddDynamics<TContext, TSource, TChecker, TLoader>(this ITerminalBuilder builder) where TContext : class where TSource : class, ITerminalCommandSource<TContext> where TChecker : class, ITerminalCommandSourceChecker<TContext> where TLoader : class, ITerminalCommandSourceAssemblyLoader<TContext>

Parameters

builder ITerminalBuilder

The terminal builder to which the integration services are added.

Returns

ITerminalBuilder

The ITerminalBuilder with the added integration services, enabling method chaining.

Type Parameters

TContext

The type of the context used in the command source, checker, and loader. Must be a class.

TSource

The type of the terminal command source. Must be a class implementing ITerminalCommandSource<TContext>.

TChecker

The type of the terminal command source checker. Must be a class implementing ITerminalCommandSourceChecker<TContext>.

TLoader

The type of the terminal command source assembly loader. Must be a class implementing ITerminalCommandSourceAssemblyLoader<TContext>.

AddEventHandler<TEventHandler>(ITerminalBuilder)

Adds the ITerminalEventHandler to the service collection.

public static ITerminalBuilder AddEventHandler<TEventHandler>(this ITerminalBuilder builder) where TEventHandler : class, ITerminalEventHandler

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TEventHandler

AddExceptionHandler<THandler>(ITerminalBuilder)

Adds the ITerminalExceptionHandler to the service collection.

public static ITerminalBuilder AddExceptionHandler<THandler>(this ITerminalBuilder builder) where THandler : class, ITerminalExceptionHandler

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

THandler

The ITerminalExceptionHandler type.

AddHelpProvider<THelpProvider>(ITerminalBuilder)

Adds the command ITerminalHelpProvider to the service collection.

public static ITerminalBuilder AddHelpProvider<THelpProvider>(this ITerminalBuilder builder) where THelpProvider : class, ITerminalHelpProvider

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

THelpProvider

AddLicensing(ITerminalBuilder)

Adds terminal license handler to the service collection.

public static ITerminalBuilder AddLicensing(this ITerminalBuilder builder)

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

AddOptionChecker<TMapper, TChecker>(ITerminalBuilder)

Adds the IDataTypeMapper<TValue> and IOptionChecker to the service collection.

public static ITerminalBuilder AddOptionChecker<TMapper, TChecker>(this ITerminalBuilder builder) where TMapper : class, IDataTypeMapper<Option> where TChecker : class, IOptionChecker

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TMapper

The option mapper type.

TChecker

The option checker type.

AddProcessor<TTerminalProcessor>(ITerminalBuilder)

Adds the ITerminalProcessor to the service collection.

public static ITerminalBuilder AddProcessor<TTerminalProcessor>(this ITerminalBuilder builder) where TTerminalProcessor : class, ITerminalProcessor

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TTerminalProcessor

The terminal processor type.

AddTerminalRouterContext<TContext>(ITerminalBuilder, TContext)

Adds the TerminalRouterContext to the service collection.

public static ITerminalBuilder AddTerminalRouterContext<TContext>(this ITerminalBuilder builder, TContext terminalRouterContext) where TContext : TerminalRouterContext

Parameters

builder ITerminalBuilder

The builder.

terminalRouterContext TContext

The terminal router context.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TContext

AddTerminalRouter<TRouter, TContext>(ITerminalBuilder)

Adds the ITerminalRouter<TContext> to the service collection.

public static ITerminalBuilder AddTerminalRouter<TRouter, TContext>(this ITerminalBuilder builder) where TRouter : class, ITerminalRouter<TContext> where TContext : TerminalRouterContext

Parameters

builder ITerminalBuilder

The builder.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TRouter
TContext

AddTextHandler<TTextHandler>(ITerminalBuilder, TTextHandler)

Adds the ITerminalTextHandler to the service collection.

public static ITerminalBuilder AddTextHandler<TTextHandler>(this ITerminalBuilder builder, TTextHandler textHandler) where TTextHandler : class, ITerminalTextHandler

Parameters

builder ITerminalBuilder

The builder.

textHandler TTextHandler

The text handler.

Returns

ITerminalBuilder

The configured ITerminalBuilder.

Type Parameters

TTextHandler

The text handler.

Remarks

AddTextHandler<TTextHandler>(ITerminalBuilder, TTextHandler) requires an instance of TTextHandler instead of just its type because the terminal application is expected to operate with a single, consistent instance of ITerminalTextHandler throughout its lifetime. By passing an instance, it allows the terminal to maintain state or configuration specific to that instance, ensuring consistent text handling behavior across different parts of the application.

This approach also facilitates more flexible initialization patterns, where the ITerminalTextHandler can be configured or initialized outside of the dependency injection container before being registered. This can be particularly useful when the text handler requires complex setup or depends on settings or services that aren't readily available within the DI context.

DefineCommand<TRunner>(ITerminalBuilder, string, string, string, CommandType, CommandFlags)

Starts a new ICommandBuilder definition with the default CommandChecker. Applications must call the Add() method to add the CommandDescriptor to the service collection.

public static ICommandBuilder DefineCommand<TRunner>(this ITerminalBuilder builder, string id, string name, string description, CommandType commandType, CommandFlags commandFlags) where TRunner : ICommandRunner<CommandRunnerResult>

Parameters

builder ITerminalBuilder

The builder.

id string

The command id.

name string

The command name.

description string

The command description.

commandType CommandType

The command type.

commandFlags CommandFlags

The command flags.

Returns

ICommandBuilder

The configured ITerminalBuilder.

Type Parameters

TRunner

The command runner type.