/// <summary> /// Apply a command operation /// </summary> /// <param name="observed">observed operation</param> /// <param name="activator">command parameters</param> /// <returns>command operation</returns> public static CommandOperation DbCommand(this IObservableOperation observed, CommandActivator activator) { var cmd = new CommandOperation(activator); observed.Subscribe(cmd); return(cmd); }
public void NullCheck() { IServiceProvider provider = CreateDependencyInjection(); Assert.Throws <ArgumentNullException>("provider", () => CommandActivator.ConstructCommand(null, typeof(NullCommand))); Assert.Throws <ArgumentNullException>("type", () => CommandActivator.ConstructCommand(provider, null)); }
private void SubmitInput() { // get current input Input input = GetCurrentInput(); // update command history if (_submitHistory.Count == 0 || !_submitHistory.LastOrDefault().Equals(input.ToString().Trim())) { _submitHistory.Add(input.ToString().TrimEnd()); _submitHistoryIndex = _submitHistory.Count; } Out.Standard.WriteLine(); // resolve command CommandResolver resolver = new CommandResolver(input, Commands); if (resolver.HasErrors) // if resolution failed with errors, output errors here { foreach (var err in resolver.Errors) { Out.Error.WriteLine(err); } CommandExecutionComplete(null); } else { var cmd = new CommandActivator().Create(resolver, this); InputFilters.SetFilterMode(FilterMode.Execution); _invoker.Invoke(cmd, false, CommandExecutionComplete); } }
/// <summary> /// Apply a command operation /// </summary> /// <param name="observed">observed operation</param> /// <param name="activator">command parameters</param> /// <returns>command operation</returns> public static CommandOperation DbCommand(this IObservableOperation observed, CommandActivator activator) { var cmd = new CommandOperation(activator, LogProvider.GetLogger(typeof(CommandOperation).ToString())); observed.Subscribe(cmd); return(cmd); }
public void SetupCommandActivatorTest() { keyActivationProvider = new Mock <IKeyCommandActivationProvider>(); signatureActivationProvider = new Mock <ISignatureCommandActivationProvider>(); activator = new CommandActivator(keyActivationProvider.Object, signatureActivationProvider.Object); arguments = new ApplicationArguments(); }
public void CreateCommandWithParameterlessConstructor() { IServiceProvider provider = CreateDependencyInjection(); CommandBase command = CommandActivator.ConstructCommand(provider, typeof(NullCommand)); Assert.IsType <NullCommand>(command); }
public void ActivatorRequiresPublicConstructor() { IServiceProvider provider = CreateDependencyInjection(); Type type = typeof(InvalidCommand); Assert.Empty(type.GetConstructors()); Assert.Throws <InvalidOperationException>(() => CommandActivator.ConstructCommand(provider, type)); }
public void CreateCommandWithParameterizedConstructor() { Func <int> argument = () => 240; IServiceProvider provider = CreateDependencyInjection(argument); CommandBase command = CommandActivator.ConstructCommand(provider, typeof(DelegateCommand)); Assert.IsType <DelegateCommand>(command); }
/// <summary> /// Apply a command operation /// </summary> /// <param name="observed">observed operation</param> /// <param name="act">callback on command activator</param> /// <returns>command operation</returns> public static CommandOperation DbCommand(this IObservableOperation observed, Action <CommandActivator> act) { var activator = new CommandActivator(); act(activator); CommandOperation cmd = new CommandOperation(activator); observed.Subscribe(cmd); return(cmd); }
/// <summary> /// Apply a command operation /// </summary> /// <param name="observed">observed operation</param> /// <param name="connStr">Name of a connection string defined in the application configuration file</param> /// <param name="CommandText">text of the command</param> /// <param name="isQuery">indicate if the command is a query</param> /// <param name="prepare">callback method to prepare the command</param> /// <returns>command operation</returns> public static CommandOperation DbCommand(this IObservableOperation observed, string connStr, string CommandText, bool isQuery, Action <IDbCommand, Row> prepare) { var activator = new CommandActivator(); activator.ConnStringName = connStr; activator.CommandText = CommandText; activator.Prepare = prepare; activator.IsQuery = isQuery; return(observed.DbCommand(activator)); }
/// <summary> /// Apply a database command /// </summary> /// <param name="connection">Database connection</param> /// <param name="CommandText">Text of the command</param> /// <param name="isQuery">Indicate if the command is a query</param> /// <param name="failOnError">Indicate if the operation must fail on element error</param> /// <param name="Prepare">Callback method to prepare the command</param> /// <returns>Command operation</returns> public static InputCommandOperation Command(IDbConnection connection, string CommandText, bool isQuery, bool failOnError, Action <IDbCommand, Row> Prepare) { var activator = new CommandActivator(); activator.Connection = connection; activator.CommandText = CommandText; activator.Prepare = Prepare; activator.IsQuery = isQuery; activator.FailOnError = failOnError; return(Command(activator)); }
private static async Task <CommandResult> RunCommandPipelineAsync(ReadOnlyCollection <string> commandLineArguments, Assembly commandAssembly, IServiceProvider provider, CancellationToken stoppingToken) { CommandLineArguments args = CommandLineArgumentsParser.Parse(commandLineArguments); Type type = CommandSelector.SelectCommand(commandAssembly, args); using CommandBase instance = CommandActivator.ConstructCommand(provider, type); CommandArgumentsBinder.BindArguments(instance, args); CommandOptionsBinder.BindOptions(instance, args); CommandResult result = await CommandExecutor.InvokeAsync(instance, stoppingToken); return(result); }
public static void Initialize(TestContext ctx) { var registry = new CommandRegistry(); registry.RegisterCommand <Command>(); registry.RegisterCommand <WithArgument>(); registry.RegisterCommand <WithIntArg>(); registry.RegisterCommand <MultipleArgs>(); registry.RegisterCommand <WithAlias>(); registry.RegisterCommand <WithOption>(); _resolver = new CommandResolver(registry); _activator = new CommandActivator(); }
public MongoDbUpdateOperation(CommandActivator activator, IMongoDatabase database, string collectionName, Func <Row, MongoDB.Driver.FilterDefinition <T> > filter, Func <Row, MongoDB.Driver.UpdateDefinition <T> > update, MongoDB.Driver.UpdateOptions options = null) { _activator = activator; this.database = database; this.collectionName = collectionName; this.filter = filter; this.update = update; this.options = options; }
internal CommandLineApplication( CommandRegistry registry, IContainer container, IInterface intfc) { _registry = registry; _resolver = new CommandResolver(registry); _activator = new CommandActivator(container ?? new SystemActivatorContainer()); _interface = intfc; _interface.CancelExecutionEvent += (sender, e) => { if (IsRunning) { _currentCancellationTokenSource.Cancel(); if (e != null) { e.Cancel = true; } } }; }
/// <summary> /// Constructor of input command operation /// </summary> /// <param name="activator"></param> public InputCommandOperation(CommandActivator activator) { _activator = activator; }
/// <summary> /// Constructor of input command operation /// </summary> /// <param name="activator"></param> public InputCommandOperation(CommandActivator activator, ILogger log) { _activator = activator; this.log = log; }
/// <summary> /// Command operation constructor /// </summary> /// <param name="activator">command parameters</param> public CommandOperation(CommandActivator activator, ILogger logger) { _activator = activator; this.log = logger; }
/// <summary> /// Apply a database command /// </summary> /// <param name="activator">command parameters</param> /// <returns>command operation</returns> public static InputCommandOperation Command(CommandActivator activator) { var cmd = new InputCommandOperation(activator); return(cmd); }
/// <summary> /// Command operation constructor /// </summary> /// <param name="activator">command parameters</param> public CommandOperation(CommandActivator activator) => _activator = activator;
/// <summary> /// Apply a database command /// </summary> /// <param name="activator">command parameters</param> /// <returns>command operation</returns> public static InputCommandOperation Command(CommandActivator activator) { var cmd = new InputCommandOperation(activator, LogProvider.GetLogger(typeof(InputCommandOperation).ToString())); return(cmd); }
public void ActivatorDoesNotCatchExceptionThrownInCommandConstructor() { IServiceProvider provider = CreateDependencyInjection(); Assert.Throws <NotSupportedException>(() => CommandActivator.ConstructCommand(provider, typeof(BadCommand))); }
public void TypeMustBeCommand() { IServiceProvider provider = CreateDependencyInjection(); Assert.Throws <ArgumentException>("type", () => CommandActivator.ConstructCommand(provider, typeof(CommandActivatorTests))); }