public void AddBranch <TDerivedSettings>(string name, Action <IConfigurator <TDerivedSettings> > action) where TDerivedSettings : TSettings { var command = ConfiguredCommand.FromBranch <TDerivedSettings>(name); action(new Configurator <TDerivedSettings>(command, _registrar)); _command.Children.Add(command); }
public void AddBranch <TSettings>(string name, Action <IConfigurator <TSettings> > action) where TSettings : CommandSettings { var command = ConfiguredCommand.FromBranch <TSettings>(name); action(new Configurator <TSettings>(command, _registrar)); Commands.Add(command); }
void IUnsafeConfigurator.AddBranch(string name, Type settings, Action <IUnsafeBranchConfigurator> action) { var command = ConfiguredCommand.FromBranch(settings, name); // Create the configurator. var configuratorType = typeof(Configurator <>).MakeGenericType(settings); if (!(Activator.CreateInstance(configuratorType, new object?[] { command, _registrar }) is IUnsafeBranchConfigurator configurator)) { throw new CommandConfigurationException("Could not create configurator by reflection."); } action(configurator); _command.Children.Add(command); }