Esempio n. 1
0
        protected QueryMiddlewareBase(
            RequestDelegate next,
            IPathOptionAccessor options,
            IQueryResultSerializer serializer,
            IErrorHandler errorHandler)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _serializer = serializer
                          ?? throw new ArgumentNullException(nameof(serializer));
            ErrorHandler = errorHandler
                           ?? throw new ArgumentNullException(nameof(serializer));

            Next = next;

            if (options.Path.Value.Length > 1)
            {
                var        path1 = new PathString(options.Path.Value.TrimEnd('/'));
                PathString path2 = path1.Add(new PathString("/"));
                _isPathValid = ctx => ctx.IsValidPath(path1, path2);
            }
            else
            {
                _isPathValid = ctx => ctx.IsValidPath(options.Path);
            }
        }
        /// <summary>
        /// Instantiates the base query middleware with an optional pointer to
        /// the next component.
        /// </summary>
        /// <param name="next">
        /// An optional pointer to the next component.
        /// </param>
        /// <param name="queryExecutor">
        /// A required query executor resolver.
        /// </param>
        /// <param name="resultSerializer">
        /// </param>
        /// <param name="options">
        /// </param>
        protected QueryMiddlewareBase(
            RequestDelegate next,
            IPathOptionAccessor options,
            OwinContextAccessor owinContextAccessor,
            IServiceProvider services)
            : base(next)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _accessor = owinContextAccessor;
            _services = services
                        ?? throw new ArgumentNullException(nameof(services));

            if (options.Path.Value.Length > 1)
            {
                var        path1 = new PathString(options.Path.Value.TrimEnd('/'));
                PathString path2 = path1.Add(new PathString("/"));
                _isPathValid = ctx => ctx.IsValidPath(path1, path2);
            }
            else
            {
                _isPathValid = ctx => ctx.IsValidPath(options.Path);
            }
        }
        protected QueryMiddlewareBase(
            RequestDelegate next,
            IPathOptionAccessor options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            Next = next;

            if (options.Path.Value.Length > 1)
            {
                var        path1 = new PathString(options.Path.Value.TrimEnd('/'));
                PathString path2 = path1.Add(new PathString("/"));
                _isPathValid = ctx => ctx.IsValidPath(path1, path2);
            }
            else
            {
                _isPathValid = ctx => ctx.IsValidPath(options.Path);
            }
        }