示例#1
0
        /// <summary>
        ///
        /// </summary>
        public CallNotifier(RunnerService service, ICommand command, string name, Predicate <string>?predicate = null)
        {
            service = service ?? throw new ArgumentNullException(nameof(service));
            Command = command ?? throw new ArgumentNullException(nameof(command));

            service.CallRunning += (_, call) =>
            {
                if (!string.Equals(call.Command.Name, name, StringComparison.Ordinal))
                {
                    return;
                }
                if (predicate != null && !predicate(call.Command.Input.Argument))
                {
                    return;
                }

                OnEventOccurred();
            };
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        public ProcessSequenceRunner(RunnerService runnerService)
        {
            RunnerService = runnerService ?? throw new ArgumentNullException(nameof(runnerService));

            Add(new ProcessAction("process-sequence", async(process, command, cancellationToken) =>
            {
                var count    = int.Parse(command.Input.Arguments.ElementAt(0), CultureInfo.InvariantCulture);
                var commands = command.Input.Arguments
                               .Skip(1)
                               .Take(count)
                               .Select(Command.Parse)
                               .Cast <ICommand>()
                               .ToArray();
                var arguments = command.Input.Arguments
                                .Skip(1 + count)
                                .ToArray();

                await ProcessSequenceAsync(commands, process, arguments, cancellationToken)
                .ConfigureAwait(false);

                return(Value.Empty);
            }));
        }