Class CommandFactory
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
authServiceIAuthenticationServiceThe authentication service used by authentication-related commands.
scheduleManagerSchedulerServiceThe scheduler service used by scheduling-related commands.
profileServiceProfileServiceThe profile service used by profile-related commands.
clinicalDocServiceClinicalDocumentServiceThe 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
commandIdentifierstringThe command name or key to check.
Returns
- bool
trueif the command exists; otherwise,false.
CreateCommand(string)
Creates a command by name or key.
public ICommand? CreateCommand(string commandIdentifier)
Parameters
commandIdentifierstringThe command name or key (case-insensitive).
Returns
- ICommand
An instance of the requested command, or
nullif 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
commandIdentifierstringThe command name or key (case-insensitive).
parameterValuesDictionary<string, object>The parameter values to populate the CommandParameters instance.
Returns
- (ICommand Command, CommandParameters Parameters)
A tuple containing the created command (or
nullif 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
commandIdentifierstringThe 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
commandKeystringThe command key.
Returns
GetCommandsForRole(UserRole)
Gets the command keys that are available for a specific user role.
public IEnumerable<string> GetCommandsForRole(UserRole role)
Parameters
roleUserRoleThe role for which to retrieve available commands.
Returns
- IEnumerable<string>
An ordered collection of command keys that the specified role can access.