Beispiel #1
0
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters

        /// <summary>
        /// Constructor that requires an explicit implementation of
        /// <see cref="ILoopClient"/>.
        /// </summary>
        /// <param name="commandType">Type that defines syntax for commands.</param>
        /// <param name="loopClient">The client to use.</param>
        /// <param name="argSetAttribute">Optionally provides attribute info
        /// for the argument set that will be dynamically created for this loop.</param>
        /// <param name="options">Optionally provides additional options for
        /// this loop's execution.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="commandType" />
        /// is null.</exception>
        public Loop(Type commandType, ILoopClient loopClient, ArgumentSetAttribute argSetAttribute = null, LoopOptions options = null)
        {
            if (commandType == null)
            {
                throw new ArgumentNullException(nameof(commandType));
            }

            _client = loopClient ?? throw new ArgumentNullException(nameof(loopClient));
            _client.TokenCompleter = new TokenCompleter(this);

            _options = options?.DeepClone() ?? new LoopOptions();
            _options.ParserOptions.DisplayUsageInfoOnError = false;
            _options.ParserOptions.Reporter = error => _client.OnError(error.ToString().TrimEnd());

            var inputConfigurer = _options.ParserOptions.ServiceConfigurer;

            _options.ParserOptions.ServiceConfigurer = collection => ConfigureServices(collection, inputConfigurer);

            var constructedType = ConstructCommandTypeFactory(commandType, out _objectFactory);

            _argSet = AttributeBasedArgumentDefinitionFactory.CreateArgumentSet(
                constructedType,
                attribute: argSetAttribute,
                serviceConfigurer: _options.ParserOptions.ServiceConfigurer);
        }
Beispiel #2
0
        public Search(ILoopClient loopClient)
        {
            _loopClient = loopClient;

            Select = new List <object>();
            Where  = new List <object>();
            Offset = 0;
            Limit  = 100;
        }
Beispiel #3
0
 /// <summary>
 /// Constructor that requires an explicit implementation of
 /// <see cref="ILoopClient"/>.
 /// </summary>
 /// <param name="loopClient">The client to use.</param>
 /// <param name="options">Options for loop.</param>
 public Loop(ILoopClient loopClient, LoopOptions options = null) : this(options)
 {
     Client = loopClient ?? throw new ArgumentNullException(nameof(loopClient));
 }