Table of Contents

Class CommandFactory

Namespace
Core.CliniCore.Commands
Assembly
Core.CliniCore.dll

Factory for creating command instances based on command names or types. Uses the CommandKey property for consistent command identification.

public class CommandFactory
Inheritance
CommandFactory
Inherited Members

Constructors

CommandFactory(IAuthenticationService, SchedulerService, ProfileService, ClinicalDocumentService)

Initializes a new instance of the CommandFactory class.

public CommandFactory(IAuthenticationService authService, SchedulerService scheduleManager, ProfileService profileService, ClinicalDocumentService clinicalDocService)

Parameters

authService IAuthenticationService

The authentication service used by authentication-related commands.

scheduleManager SchedulerService

The scheduler service used by scheduling-related commands.

profileService ProfileService

The profile service used by profile-related commands.

clinicalDocService ClinicalDocumentService

The clinical document service used by clinical documentation commands.

Exceptions

ArgumentNullException

Thrown when any required service dependency is null.

Methods

CommandExists(string)

Determines whether a command exists for the specified identifier.

public bool CommandExists(string commandIdentifier)

Parameters

commandIdentifier string

The command name or key to check.

Returns

bool

true if the command exists; otherwise, false.

CreateCommand(string)

Creates a command by name or key.

public ICommand? CreateCommand(string commandIdentifier)

Parameters

commandIdentifier string

The command name or key (case-insensitive).

Returns

ICommand

An instance of the requested command, or null if the command cannot be resolved.

CreateCommandWithParameters(string, Dictionary<string, object?>)

Creates a command with pre-populated parameters.

public (ICommand? Command, CommandParameters Parameters) CreateCommandWithParameters(string commandIdentifier, Dictionary<string, object?> parameterValues)

Parameters

commandIdentifier string

The command name or key (case-insensitive).

parameterValues Dictionary<string, object>

The parameter values to populate the CommandParameters instance.

Returns

(ICommand Command, CommandParameters Parameters)

A tuple containing the created command (or null if not found) and the associated parameters.

GetAvailableCommands()

Gets all available command keys.

public IEnumerable<string> GetAvailableCommands()

Returns

IEnumerable<string>

A sorted collection of available command keys.

GetCommandHelp(string)

Gets descriptive help information for a specific command.

public string GetCommandHelp(string commandIdentifier)

Parameters

commandIdentifier string

The command name or key.

Returns

string

A short help string describing the command, or an error message if not found.

GetCommandType(string)

Gets the command type for a given key.

public Type? GetCommandType(string commandKey)

Parameters

commandKey string

The command key.

Returns

Type

The command Type if registered; otherwise, null.

GetCommandsForRole(UserRole)

Gets the command keys that are available for a specific user role.

public IEnumerable<string> GetCommandsForRole(UserRole role)

Parameters

role UserRole

The role for which to retrieve available commands.

Returns

IEnumerable<string>

An ordered collection of command keys that the specified role can access.