示例#1
0
 public ActionPipe(
     Func <TInput, Task> action,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.action = action;
 }
 public MappingPipe(
     Func <TInput, Task <TOutput> > mapping,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.mapping = mapping;
 }
示例#3
0
 public static OutputPipe <TInput> CurrentUserHas <TInput>(
     this IOutputPipe <TInput> pipe,
     Func <ClaimsPrincipal, TInput, bool> predicate,
     object error = null)
     where TInput : class =>
 pipe.GetRequiredService <IClaimValidationPipeFactory <TInput> >()
 .Resolve(predicate, error, pipe);
示例#4
0
 public EntityDeletionPipe(
     DbContext context,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.context = context;
 }
示例#5
0
 public static OutputPipe <TInput> CurrentUserHasClaim <TInput>(
     this IOutputPipe <TInput> pipe,
     string claimType,
     Func <TInput, string> claim,
     object error = null)
     where TInput : class =>
 pipe.CurrentUserHas((p, e) => p.HasClaim(claimType, claim(e)), error);
示例#6
0
 public QueryablePipe(
     Func <TInput, TOutput> callback,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.callback = callback;
 }
 public static OutputPipe <TEntity> InvalidWhen <TEntity>(
     this IOutputPipe <TEntity> pipe,
     Func <TEntity, bool> invalidCheck,
     int statusCode,
     object error = null)
     where TEntity : class =>
 pipe.InvalidWhen(e => Task.FromResult(invalidCheck(e)), statusCode, error);
示例#8
0
 public Logger(IOutputPipe stdout, IOutputPipe stderr, bool timestamp = true, bool loggingLevel = true)
 {
     this.stdout       = stdout;
     this.stderr       = stderr;
     this.timestamp    = timestamp;
     this.loggingLevel = loggingLevel;
 }
示例#9
0
 public static OutputPipe <TInput> InvalidWhen <TInput>(
     this IOutputPipe <TInput> pipe,
     Func <bool> invalidCheck,
     int statusCode,
     object error = null)
     where TInput : class =>
 pipe.InvalidWhen(() => Task.FromResult(invalidCheck()), statusCode, error);
示例#10
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()));
        }
示例#11
0
        public static Task <IActionResult> ToOkResult <TInput>(
            this IOutputPipe <TInput> pipe)
            where TInput : class
        {
            IPipe resultPipe = new OkResultPipe <TInput>(pipe);

            return(resultPipe.Execute());
        }
示例#12
0
 public Logger(IOutputPipe stdout, IOutputPipe stderr, bool timestamp = true, bool loggingLevel = true)
 {
     this.stdout                 = stdout;
     this.stderr                 = stderr;
     this.timestamp              = timestamp;
     this.loggingLevel           = loggingLevel;
     this.JsonSerializerSettings = new JsonSerializerSettings();
 }
 public OutputPipe <RestEntityCollection> Resolve(
     Func <TInput, TOutput> mapping, IOutputPipe <IQueryable <TInput> > parent) =>
 new CollectionMappingPipe <TInput, TOutput>(
     mapping,
     this.linkGenerator,
     this.paginationMetaInfoStorage,
     this.queryableTransformer,
     parent);
示例#14
0
 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);
 public QueryableSourcePipe(
     Func <IQueryableFactory, TInput, IQueryable <TOutput> > queryablePipe,
     IQueryableFactory queryableFactory,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.queryablePipe    = queryablePipe;
     this.queryableFactory = queryableFactory;
 }
 public ValidationPipe(
     Func <Task <bool> > invalidCheck,
     int statusCode,
     object error,
     IOutputPipe <TInput> parent)
     : base(statusCode, error, parent)
 {
     this.invalidCheck = invalidCheck;
 }
示例#17
0
 public FirstOrDefaultPipe(
     Expression <Func <TInput, bool> > predicate,
     IQueryableTransformer <TInput> queryableTransformer,
     IOutputPipe <IQueryable <TInput> > parent)
     : base(parent)
 {
     this.predicate            = predicate;
     this.queryableTransformer = queryableTransformer;
 }
 public EntityInsertionPipe(
     DbContext context,
     IScopedStorage <TInput> storage,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.context = context;
     this.storage = storage;
 }
 protected ValidationPipeBase(
     int statusCode,
     object error,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.statusCode = statusCode;
     this.error      = error;
 }
 public CreatedEntityResultPipe(
     Func <TInput, object> routeValuesGenerator,
     string routeName,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.routeValuesGenerator = routeValuesGenerator;
     this.routeName            = routeName;
 }
 public CreatedEntityResultPipe(
     Func <IServiceProvider, object> routeValuesGenerator,
     string routeName,
     IOutputPipe <TInput> parent)
     : base(parent)
 {
     this.routeValuesGenerator = t => routeValuesGenerator(this);
     this.routeName            = routeName;
 }
 public FilterByClientRequestPipe(
     IDictionary <string, IFilterExpressionProvider <TInput> > filterDictionary,
     IFilterByClientRequestInterpreter interpreter,
     IOutputPipe <IQueryable <TInput> > parent)
     : base(parent)
 {
     this.filterDictionary = filterDictionary;
     this.interpreter      = interpreter;
 }
 public OutputPipe <IQueryable <TInput> > Resolve(
     PaginationOptions options,
     IOutputPipe <IQueryable <TInput> > parent) =>
 new PaginationByClientRequestPipe <TInput>(
     options,
     this.interpreter,
     this.paginationMetaInfoStorage,
     this.queryableTransformer,
     parent);
示例#24
0
 public OrderByClientRequestPipe(
     IDictionary <string, IOrderByExpressionFactory <TInput> > orderByDictionary,
     IOrderByClientRequestInterpreter orderByClientRequestInterpreter,
     IOutputPipe <IQueryable <TInput> > parent)
     : base(parent)
 {
     this.orderByDictionary = orderByDictionary;
     this.orderByClientRequestInterpreter = orderByClientRequestInterpreter;
 }
示例#25
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)));
        }
示例#26
0
 public ClaimValidationPipe(
     Func <ClaimsPrincipal, TInput, bool> validCheck,
     ClaimsPrincipal principal,
     object error,
     IOutputPipe <TInput> parent)
     : base(StatusCodes.Status403Forbidden, error, parent)
 {
     this.principal  = principal;
     this.validCheck = validCheck;
 }
示例#27
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="characterReader">InputPipe to use for reading single characters.</param>
 public JsonRpcPipe(IInputPipe characterReader, IOutputPipe characterWriter)
 {
     this.characterReader        = characterReader;
     this.characterWriter        = characterWriter;
     this.blockQueue             = new ConcurrentQueue <object>();
     this.JsonSerializerSettings = new JsonSerializerSettings()
     {
         NullValueHandling = NullValueHandling.Ignore
     };
 }
示例#28
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)));
        }
示例#29
0
        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)));
        }
示例#30
0
        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)));
        }
		/// <summary>
		/// Constructs the XML output pipe.
		/// </summary>
		/// <param name="outputPipe">The target output pipe which to write to.</param>
		public JsonOutputPipe(IOutputPipe outputPipe)
		{
			// validate arguments
			if (outputPipe == null)
				throw new ArgumentNullException("outputPipe");

			// set values
			this.outputPipe = outputPipe;

			// create the reader
			jsonWriter = new JsonTextWriter(outputPipe.Writer)
			             {
			             	CloseOutput = false,
			             	Formatting = Formatting.None
			             };
		}
示例#32
0
		/// <summary>
		/// Constructs the XML output pipe.
		/// </summary>
		/// <param name="outputPipe">The target output pipe which to write to.</param>
		public XmlOutputPipe(IOutputPipe outputPipe)
		{
			// validate arguments
			if (outputPipe == null)
				throw new ArgumentNullException("outputPipe");

			// set values
			this.outputPipe = outputPipe;

			// create the reader
			xmlWriter = XmlWriter.Create(outputPipe.Writer, new XmlWriterSettings
			                                                {
			                                                	CloseOutput = false,
																				NamespaceHandling = NamespaceHandling.OmitDuplicates
			                                                });

			// create the namespace manager
			NamespaceManager = new XmlNamespaceManager(new NameTable());
		}
示例#33
0
		/// <summary>
		/// Constructs the XML output pipe.
		/// </summary>
		/// <param name="outputPipe">The target output pipe which to write to.</param>
		/// <param name="format">The <see cref="CsvOutputFormat"/> which to use.</param>
		public CsvOutputPipe(IOutputPipe outputPipe, CsvOutputFormat format)
		{
			// validate arguments
			if (outputPipe == null)
				throw new ArgumentNullException("outputPipe");
			if (format == null)
				throw new ArgumentNullException("format");

			// set values
			this.outputPipe = outputPipe;
			this.format = format;

			// write the document start delimitor when available
			if (format.HasDocumentStartDelimitor)
				outputPipe.Writer.Write(format.DocumentStartDelimitor);

			// write the column headers when needed
			if (format.IncludeColumnHeaders)
				Write(format.ColumnHeaders);
		}