示例#1
0
        public static Task <IActionResult> ToOptionsResult <TInput>(
            this IOutputPipe <TInput> pipe,
            params HttpVerb[] verbs)
            where TInput : class
        {
            var   httpContextStorage = pipe.GetService <IScopedStorage <HttpContext> >();
            var   httpVerbMap        = pipe.GetService <IHttpVerbMap>();
            IPipe resultPipe         = new OptionsResultPipe <TInput>(
                input => verbs, httpVerbMap, httpContextStorage, pipe);

            return(resultPipe.Execute());
        }
示例#2
0
        public static Task <IActionResult> ToOptionsResult <TInput>(
            this IOutputPipe <TInput> pipe,
            Func <IAllowedOptionsBuilder <TInput>, IAllowedOptionsBuilder <TInput> > builder)
            where TInput : class
        {
            var   allowedOptionsBuilder = pipe.GetService <IAllowedOptionsBuilder <TInput> >();
            var   httpContextStorage    = pipe.GetService <IScopedStorage <HttpContext> >();
            var   httpVerbMap           = pipe.GetService <IHttpVerbMap>();
            IPipe resultPipe            = new OptionsResultPipe <TInput>(
                input => builder(allowedOptionsBuilder).GenerateAllowedVerbs(input),
                httpVerbMap,
                httpContextStorage,
                pipe);

            return(resultPipe.Execute());
        }
 public static OutputPipe <TEntity> InvalidWhen <TEntity>(
     this IOutputPipe <TEntity> pipe,
     Func <TEntity, Task <bool> > invalidCheck,
     int statusCode,
     object error = null)
     where TEntity : class =>
 pipe.GetService <IEntityValidationPipeFactory <TEntity> >()
 .Resolve(invalidCheck, statusCode, error, pipe);
示例#4
0
        public static OutputPipe <IQueryable <TInput> > ApplyOrderByClientRequest <TInput>(
            this IOutputPipe <IQueryable <TInput> > pipe,
            Func <IOrderByExpressionBuilder <TInput>, IOrderByExpressionBuilder <TInput> > builder)
        {
            var orderByExpressionBuilder = pipe.GetService <IOrderByExpressionBuilder <TInput> >();

            return(pipe.ApplyOrderByClientRequest(builder(orderByExpressionBuilder).Build()));
        }
示例#5
0
        public static OutputPipe <TOutput> BuildMapping <TInput, TOutput>(
            this IOutputPipe <TInput> pipe,
            Func <IMappingBuilder <TInput>, Func <TInput, TOutput> > builder)
            where TInput : class
            where TOutput : class
        {
            var mappingBuilder = pipe.GetService <IMappingBuilder <TInput> >();

            return(pipe.Map(builder(mappingBuilder)));
        }
示例#6
0
        public static OutputPipe <TOutput> UseMapper <TInput, TOutput>(
            this IOutputPipe <TInput> pipe,
            Func <IMapperFactory <TInput>, IMapper <TInput, TOutput> > selection)
            where TInput : class
            where TOutput : class
        {
            var mapper = pipe.GetService <IMapperFactory <TInput> >();

            return(pipe.Map(i => selection(mapper).Map(i)));
        }
        public static OutputPipe <RestEntityCollection> BuildMappingForCollection <TInput, TOutput>(
            this IOutputPipe <IQueryable <TInput> > pipe,
            Func <IMappingBuilder <TInput>, Func <TInput, TOutput> > builder)
            where TInput : class
            where TOutput : class
        {
            var transformerBuilder = pipe.GetService <IMappingBuilder <TInput> >();

            return(pipe.MapToRestCollection(builder(transformerBuilder)));
        }
        public static OutputPipe <RestEntityCollection> UseMapperForCollection <TInput, TOutput>(
            this IOutputPipe <IQueryable <TInput> > pipe,
            Func <IMapperFactory <TInput>, IMapper <TInput, TOutput> > selection)
            where TInput : class
            where TOutput : class
        {
            var transformer = pipe.GetService <IMapperFactory <TInput> >();

            return(pipe.MapToRestCollection(i => selection(transformer).Map(i)));
        }
示例#9
0
        public static OutputPipe <TInput> Do <TInput>(
            this IOutputPipe <TInput> pipe, Action <TInput> action)
            where TInput : class
        {
            Func <TInput, Task> asyncAction = entity =>
            {
                action(entity);
                return(Task.FromResult(0));
            };

            return(pipe.GetService <IActionPipeFactory <TInput> >().Resolve(asyncAction, pipe));
        }
示例#10
0
 public static OutputPipe <TInput> SingleOrDefault <TInput>(
     this IOutputPipe <IQueryable <TInput> > pipe, Expression <Func <TInput, bool> > predicate)
     where TInput : class =>
 pipe.GetService <ISingleOrDefaultPipeFactory <TInput> >().Resolve(predicate, pipe);
示例#11
0
 public static OutputPipe <TOutputQueryable> MapQueryable <TInputQueryable, TOutputQueryable>(
     this IOutputPipe <TInputQueryable> pipe, Func <TInputQueryable, TOutputQueryable> mapping)
     where TInputQueryable : class, IQueryable
     where TOutputQueryable : class, IQueryable =>
 pipe.GetService <IQueryablePipeFactory <TInputQueryable, TOutputQueryable> >()
 .Resolve(mapping, pipe);
示例#12
0
 public static OutputPipe <IQueryable <TInput> > ApplySearchByClientRequest <TInput>(
     this IOutputPipe <IQueryable <TInput> > pipe,
     Func <string, Expression <Func <TInput, bool> > > search) =>
 pipe.GetService <ISearchByClientRequestPipeFactory <TInput> >()
 .Resolve(search, pipe);
示例#13
0
 public static OutputPipe <TInput> Do <TInput>(
     this IOutputPipe <TInput> pipe, Func <TInput, Task> action)
     where TInput : class =>
 pipe.GetService <IActionPipeFactory <TInput> >().Resolve(action, pipe);
示例#14
0
 public static OutputPipe <IQueryable <TInput> > ApplyPaginationByClientRequest <TInput>(
     this IOutputPipe <IQueryable <TInput> > pipe,
     PaginationOptions options = null) =>
 pipe.GetService <IPaginationByClientRequestPipeFactory <TInput> >()
 .Resolve(options, pipe);
示例#15
0
 public static OutputPipe <IQueryable <TInput> > ApplyOrderByClientRequest <TInput>(
     this IOutputPipe <IQueryable <TInput> > pipe,
     IDictionary <string, IOrderByExpressionFactory <TInput> > orderByExpressions) =>
 pipe.GetService <IOrderByClientRequestPipeFactory <TInput> >()
 .Resolve(orderByExpressions, pipe);
示例#16
0
 public static OutputPipe <IQueryable <TInput> > ApplyFilterByClientRequest <TInput>(
     this IOutputPipe <IQueryable <TInput> > pipe,
     IDictionary <string, IFilterExpressionProvider <TInput> > filterExpressionProviders) =>
 pipe.GetService <IFilterByClientRequestPipeFactory <TInput> >()
 .Resolve(filterExpressionProviders, pipe);