コード例 #1
0
        public void AddCommand <TCommand>(string name) where TCommand : class, ICommandLimiter <TSettings>
        {
            var settingsType = ConfigurationHelper.GetSettingsType(typeof(TCommand));
            var command      = new ConfiguredCommand(name, typeof(TCommand), settingsType);

            _command.Children.Add(command);
            _registrar.RegisterCommand(typeof(TCommand), settingsType);
        }
コード例 #2
0
        public void AddBranch <TDerivedSettings>(string name, Action <IConfigurator <TDerivedSettings> > action)
            where TDerivedSettings : TSettings
        {
            var command = new ConfiguredCommand(name, null, typeof(TDerivedSettings));

            action(new Configurator <TDerivedSettings>(command, _registrar));
            _command.Children.Add(command);
        }
コード例 #3
0
        public void AddBranch <TSettings>(string name, Action <IConfigurator <TSettings> > action)
            where TSettings : CommandSettings
        {
            var command = new ConfiguredCommand(name, null, typeof(TSettings));

            action(new Configurator <TSettings>(command, _registrar));
            Commands.Add(command);
        }
コード例 #4
0
        public ICommandConfigurator AddCommand <TCommand>(string name) where TCommand : class, ICommand
        {
            var settingsType = ConfigurationHelper.GetSettingsType(typeof(TCommand));
            var command      = new ConfiguredCommand(name, typeof(TCommand), settingsType);
            var configurator = new CommandConfigurator(command);

            Commands.Add(command);
            _registrar.RegisterCommand(typeof(TCommand), settingsType);

            return(configurator);
        }
コード例 #5
0
        public void SetDefaultCommand <TDefaultCommand>()
            where TDefaultCommand : class, ICommand
        {
            var defaultCommand = typeof(TDefaultCommand);

            // Initialize the default command.
            var settingsType = ConfigurationHelper.GetSettingsType(defaultCommand);

            DefaultCommand = new ConfiguredCommand(Constants.DefaultCommandName, defaultCommand, settingsType, true);

            // Register the default command.
            _registrar.RegisterCommand(defaultCommand, settingsType);
        }
コード例 #6
0
        public Configurator(ITypeRegistrar registrar, Type defaultCommand = null)
        {
            _registrar = registrar;

            Commands = new List <ConfiguredCommand>();
            ShouldPropagateExceptions = false;
            ParsingMode = ParsingMode.Relaxed;

            if (defaultCommand != null)
            {
                if (!typeof(ICommand).IsAssignableFrom(defaultCommand))
                {
                    throw new ArgumentException($"The specified default command type '{defaultCommand}' is not a command.", nameof(defaultCommand));
                }

                // Initialize the default command.
                var settingsType = ConfigurationHelper.GetSettingsType(defaultCommand);
                DefaultCommand = new ConfiguredCommand(Constants.DefaultCommandName, defaultCommand, settingsType, true);

                // Register the default command.
                _registrar.RegisterCommand(defaultCommand, settingsType);
            }
        }
コード例 #7
0
 public CommandConfigurator(ConfiguredCommand command)
 {
     Command = command;
 }
コード例 #8
0
 public Configurator(ConfiguredCommand command, ITypeRegistrar registrar)
 {
     _command   = command;
     _registrar = registrar;
 }