PipelineData IPipelineStep.Run(object input) { var castedInput = Convert.ToDouble(input); Result = new PipelineData(castedInput / 10, typeof(Double)); return(Result); }
public PipelineData Process(PipelineData Input) { var Args = Input.Options as RoutedPipelineStreamOptions; var Data = Input.SecondaryData; switch (Args.Method) { case RoutedPipelineStreamMethod.READ: SideLoger.CurrentLoger.Log($"R->{Args.Context.Request.RemoteEndPoint}<<{(Data as ReadArguments).Result}"); break; case RoutedPipelineStreamMethod.SEEK: break; case RoutedPipelineStreamMethod.SETLENGTH: break; case RoutedPipelineStreamMethod.WRITE: SideLoger.CurrentLoger.Log($"W->{Args.Context.Request.RemoteEndPoint}>>{(Data as WriteArguments).Count}"); break; case RoutedPipelineStreamMethod.FLUSH: SideLoger.CurrentLoger.Log($"F->{Args.Context.Request.RemoteEndPoint}"); break; default: break; } return(Input); }
public PipelineData Process(PipelineData Input) { //if (((HttpPipelineArguments)Input.SecondaryData).isHandled == true) return Input; HttpListenerRoutedContext context = Input.PrimaryData as HttpListenerRoutedContext; Trace.WriteLine(Language.Query("LWMS.ErrorResponseUnit.UnhandledRequest", "Unhandled Http Pipeline. Request: {0}", HttpUtility.UrlDecode((context).Request.RawUrl))); if (context.Request.HttpMethod == HttpMethod.Get.Method) { var _404 = GlobalConfiguration.GetPage404(LWMSCoreServer.TrustedInstallerAuth); if (File.Exists(_404)) { Tools00.SendFile(context, new FileInfo(_404), HttpStatusCode.NotFound); } else { Tools00.SendMessage(context, "<html><body><h1>404 File Not Found</h1><hr/><p>Hosted with LWMS.</p></body></html>", HttpStatusCode.NotFound); } } else { Tools00.SendMessage(context, "<html><body><h1>Error 501</h1><hr/><p>Your request is not support yet by the server.</p></body></html>", HttpStatusCode.NotImplemented); } (Input.SecondaryData as HttpPipelineArguments).isHandled = true; return(Input); }
public PipelineData Process(PipelineData Input) { HttpListenerRoutedContext context = Input.PrimaryData as HttpListenerRoutedContext; var path0 = context.Request.Url.LocalPath.Substring(1); StorageItem Result; if (context.Request.HttpMethod == HttpMethod.Get.Method) { if (ApplicationStorage.ObtainItemFromRelativeURL(path0, out Result, false)) { if (Result.StorageItemType == StorageItemType.Folder) { StorageFile DefaultPage; if (((StorageFolder)Result).GetFile(GlobalConfiguration.GetDefaultPage(LWMSCoreServer.TrustedInstallerAuth), out DefaultPage, false)) { Tools00.SendFile(context, DefaultPage); (Input.SecondaryData as HttpPipelineArguments).isHandled = true; return(Input); } } else { Tools00.SendFile(context, Result.ToStorageFile()); (Input.SecondaryData as HttpPipelineArguments).isHandled = true; return(Input); } } } return(Input); }
public UriParametersFilter(ICommunicationContext context, IErrorCollector collector) { _context = context; Logger = NullLogger.Instance; Errors = collector; _pipelineData = context.PipelineData; }
public string GetPipelinetUrl(PipelineData pipeline) { var projectUrl = _project.WebUrl; var pipelineUrl = $"{projectUrl}/pipelines/{pipeline.Id}"; return(pipelineUrl); }
public InMemoryCommunicationContext() { ApplicationBaseUri = new Uri("http://localhost/"); Request = new InMemoryRequest(); Response = new InMemoryResponse(); ServerErrors = new List <Error>(); PipelineData = new PipelineData(); }
public PipelineConfig() { _stages = new List <IPipelineStage>(); Data = new PipelineData(); Name = GetType().FullName; AutoRaiseEvents = true; }
public InMemoryCommunicationContext() { ApplicationBaseUri = new Uri("http://local"); Request = new InMemoryRequest(); Response = new InMemoryResponse(); ServerErrors = new List<Error>(); PipelineData = new PipelineData(); }
public OwinCommunicationContext(IOwinContext nativeContext,ILogger logger) { PipelineData = new PipelineData(); _nativeContext = nativeContext; Request = new OwinRequest(nativeContext.Request); Response = new OwinResponse(nativeContext); ServerErrors = new ServerErrorList { Log = logger }; User = nativeContext.Request.User; }
public HttpListenerCommunicationContext(IHost host, HttpListenerContext nativeContext) { ServerErrors = new List<Error>(); PipelineData = new PipelineData(); _host = host; User = nativeContext.User; Request = new HttpListenerRequest(this, nativeContext.Request); Response = new HttpListenerResponse(this, nativeContext.Response); }
public AspNetCommunicationContext(ILogger logger, HttpContext context, AspNetRequest request, AspNetResponse response) { this.Log = logger; this.NativeContext = context; this.ServerErrors = new ServerErrorList { Log = logger }; PipelineData = new PipelineData(); this.Request = request; this.Response = response; }
public HttpListenerCommunicationContext(IHost host, HttpListenerContext nativeContext) { ServerErrors = new List <Error>(); PipelineData = new PipelineData(); _host = host; _nativeContext = nativeContext; User = nativeContext.User; Request = new HttpListenerRequest(this, nativeContext.Request); Response = new HttpListenerResponse(this, nativeContext.Response); }
public void InputDataReadyHandler(object sender, PipelineData <DirectoryInfo> data) { Console.WriteLine("Image loader"); var result = new PipelineData <DummyImages>() { Data = new DummyImages() }; OnOutputDataReady?.Invoke(this, result); }
public OwinCommunicationContext(IOwinContext nativeContext, ILogger logger) { PipelineData = new PipelineData(nativeContext.Environment); _nativeContext = nativeContext; Request = new OwinRequest(nativeContext.Request); Response = new OwinResponse(nativeContext); ServerErrors = new ServerErrorList { Log = logger }; _appBaseRelative = nativeContext.Request.PathBase; }
public AspNetCommunicationContext(ILogger logger, HttpContext context, AspNetRequest request, AspNetResponse response) { Log = logger; NativeContext = context; ServerErrors = new ServerErrorList { Log = logger }; PipelineData = new PipelineData(); Request = request; Response = response; }
public static DateTimeOffset GetCachingTime(this PipelineData data) { DateTimeOffset now; if (data.ContainsKey(CacheKeys.Now)) { return((DateTimeOffset)data[CacheKeys.Now]); } data[CacheKeys.Now] = now = ServerClock.UtcNow(); return(now); }
public OwinCommunicationContext(IOwinContext nativeContext, ILogger logger) { PipelineData = new PipelineData(); _nativeContext = nativeContext; Request = new OwinRequest(nativeContext.Request); Response = new OwinResponse(nativeContext); ServerErrors = new ServerErrorList { Log = logger }; User = nativeContext.Request.User; }
private async Task HandlePipelineException(PipelineData pipelineData, PipelineResult pipelineResult) { try { await _pipelineDirector.Undo(pipelineData, pipelineResult); } catch (Exception ex) { AssignException(pipelineResult, ex); _logger.AddErrorDetail(ex.Message); _logger.SubmitException(ex); } }
public PipelineData Process(PipelineData Input) { { HttpListenerRoutedContext context = Input.PrimaryData as HttpListenerRoutedContext; if (requests is null) { requests = ApplicationConfiguration.Current.GetValueArray("RoutedRequests"); } if (RouteTargets == null) { var targets = ApplicationConfiguration.Current.GetValueArray("RouteTargets"); RouteTargets = new List <MappedType>(); //Initialize the targets. foreach (var item in targets) { var parted = item.Split(','); FileInfo fi = new(parted[0]); var asm = DomainManager.LoadFromFile(context.PipelineAuth, fi.FullName); var t = asm.GetType(parted[1]); MappedType mappedType = MappedType.CreateFrom(t); RouteTargets.Add(mappedType); } } else if (RouteTargets.Count is 0) { var targets = ApplicationConfiguration.Current.GetValueArray("RouteTargets"); foreach (var item in targets) { var parted = item.Split(','); FileInfo fi = new(parted[0]); var asm = DomainManager.LoadFromFile(context.PipelineAuth, fi.FullName); var t = asm.GetType(parted[1]); MappedType mappedType = MappedType.CreateFrom(t); RouteTargets.Add(mappedType); } } var path0 = context.Request.Url.LocalPath.Substring(1); //Dispose the first '/' if (path0 is not "") //Ignore when the path is empty to prevent potential problems when performing matching. { for (int i = 0; i < requests.Length; i++) { if (path0.ToUpper().StartsWith(requests[i].ToUpper()))//Ignore case { (Input.SecondaryData as HttpPipelineArguments).isHandled = (RouteTargets[i].TargetObject as IHttpEventHandler).Handle(context, requests[i]); return(Input); } } } } return(Input); }
protected AbstractMultipartFormDataCodec(ICommunicationContext context, ICodecRepository codecs, IDependencyResolver container, ITypeSystem typeSystem, IObjectBinderLocator binderLocator) { // temporary until IRequest / IResponse are moved to the container _pipeline = context.PipelineData; _codecs = codecs; _typeSystem = typeSystem; _container = container; BinderLocator = binderLocator; Log = NullLogger<CodecLogSource>.Instance; }
protected AbstractMultipartFormDataCodec(ICommunicationContext context, ICodecRepository codecs, IDependencyResolver container, ITypeSystem typeSystem, IObjectBinderLocator binderLocator) { // temporary until IRequest / IResponse are moved to the container _pipeline = context.PipelineData; _codecs = codecs; _typeSystem = typeSystem; _container = container; BinderLocator = binderLocator; Log = NullLogger <CodecLogSource> .Instance; }
public PipelineData Process(PipelineData Input) { PipedRoutedWROption option = (PipedRoutedWROption)Input.Options; if (option.PipedRoutedWROperation == PipedRoutedWROperation.WRITE) { LWMSTraceListener.WriteFile((string)Input.PrimaryData); } else if (option.PipedRoutedWROperation == PipedRoutedWROperation.WRITELINE) { LWMSTraceListener.WriteFileLine((string)Input.PrimaryData); } return(Input); }
public SinglePipeline(Func <T> creator, IDependencyResolver resolver, Dictionary <Type, Func <ICommunicationContext, Task <PipelineContinuation> > > actions) { ContextData = new PipelineData(); _resolver = resolver; if (!_resolver.HasDependency(typeof(T))) { _resolver.AddDependency <T>(); } _list = new List <IPipelineContributor> { creator != null?creator() : resolver.Resolve <T>() }; _actions = actions; }
public SinglePipeline( Func <T> creator, IDependencyResolver resolver, Dictionary <Type, Func <ICommunicationContext, Task <PipelineContinuation> > > actions) { ContextData = new PipelineData(); var resolver1 = resolver; if (!resolver1.HasDependency(typeof(T))) { resolver1.AddDependency <T>(); } _contributor = creator != null?creator() : resolver.Resolve <T>(); _actions = actions; }
public PipelineData Process(PipelineData Input) { bool willIgnore = false; try { if (LibraryInfo.GetFlag(FeatureFlags.Pipeline_IgnoreError) == 1) { willIgnore = true; } } catch (Exception) { //Ignore } return(Process(Input, willIgnore)); }
public OwinCommunicationContext(IOwinContext nativeContext, ILogger logger) { PipelineData = new PipelineData(); foreach (var kv in nativeContext.Environment) { PipelineData.Add(kv.Key, kv.Value); } _nativeContext = nativeContext; Request = new OwinRequest(nativeContext.Request); Response = new OwinResponse(nativeContext); ServerErrors = new ServerErrorList { Log = logger }; _appBaseRelative = nativeContext.Request.PathBase; }
public PipelineData Process(PipelineData Input, bool IgnoreError) { if (IgnoreError) { foreach (var item in _processUnits) { try { if (((HttpPipelineArguments)Input.SecondaryData).isHandled == true) { return(Input); } var output = (item.TargetObject as IPipedProcessUnit).Process(Input); if (Input.CheckContinuity(output)) { Input = output; } } catch (Exception) { } } return(Input); } else { foreach (var item in _processUnits) { if (((HttpPipelineArguments)Input.SecondaryData).isHandled == true) { return(Input); } var output = (item.TargetObject as IPipedProcessUnit).Process(Input); if (Input.CheckContinuity(output)) { Input = output; } else { throw new PipelineDataContinuityException((item.TargetObject as IPipedProcessUnit)); } } return(Input); } }
public PipelineData Process(PipelineData Input) { var b = new StringBuilder(); var c = Input.PrimaryData as HttpListenerRoutedContext; b.Append(c.Request.RemoteEndPoint); b.Append(">>"); if (GlobalConfiguration.GetLogUA(LWMSCoreServer.TrustedInstallerAuth)) { b.Append(c.Request.UserAgent); b.Append(">>"); } b.Append(c.Request.HttpMethod); b.Append(">>"); b.Append(c.Request.RawUrl); Trace.WriteLine(b); return(Input); }
public PipelineData Process(PipelineData Input) { RoutedPipelineStreamOptions Options = (RoutedPipelineStreamOptions)(Input.Options); Stream BaseStream = (Stream)Input.PrimaryData; switch (Options.Method) { case RoutedPipelineStreamMethod.READ: { ReadArguments readArguments = (ReadArguments)Input.SecondaryData; readArguments.Result = BaseStream.Read(readArguments.Buffer, readArguments.Offset, readArguments.Count); } break; case RoutedPipelineStreamMethod.SEEK: { SeekArguments seekArguments = (SeekArguments)Input.SecondaryData; seekArguments.Result = BaseStream.Seek(seekArguments.Offset, seekArguments.Origin); } break; case RoutedPipelineStreamMethod.SETLENGTH: BaseStream.SetLength((long)Input.SecondaryData); break; case RoutedPipelineStreamMethod.WRITE: { WriteArguments writeArguments = (WriteArguments)Input.SecondaryData; BaseStream.Write(writeArguments.Buffer, writeArguments.Offset, writeArguments.Count); } break; case RoutedPipelineStreamMethod.FLUSH: { BaseStream.Flush(); } break; default: Trace.WriteLine("Unknown stream operation"); break; } return(Input); }
internal async Task Stage0_Split(PartitionContext context, IEnumerable <EventData> messages) { foreach (EventData eventData in messages) { try { using (var eventStream = eventData.GetBodyStream()) { using (var sr = new StreamReader(eventStream, Encoding.UTF8)) { string line; while ((line = await sr.ReadLineAsync()) != null) { var data = new PipelineData { JSON = line, PartitionId = context.Lease.PartitionId, PartitionKey = eventData.PartitionKey, Offset = eventData.Offset }; // TODO: ArrayBuffer to avoid string allocation... // also just send char ref + offset + length if (!await this.deserializeBlock.SendAsync(data)) { this.telemetry.TrackTrace("Failed to enqueue data"); } } this.performanceCounters.Stage0_IncomingBytesPerSec.IncrementBy(eventStream.Position); this.performanceCounters.Stage0_Batches_Size.IncrementBy(eventStream.Position); this.performanceCounters.Stage0_Batches_SizeBase.Increment(); } } this.performanceCounters.Stage0_BatchesPerSec.Increment(); this.performanceCounters.Stage0_Batches_Total.Increment(); } catch (Exception ex) { this.telemetry.TrackException(ex); } } }
public HttpListenerCommunicationContext(IHost host, HttpListenerContext nativeContext, ILogger logger) { ServerErrors = new ServerErrorList { Log = logger }; PipelineData = new PipelineData { Owin = { SslLoadClientCertAsync = LoadClientCert } }; _host = host; _nativeContext = nativeContext; User = nativeContext.User; Request = new HttpListenerRequest(this, nativeContext.Request); Response = new HttpListenerResponse(this, nativeContext.Response); }
public void SetUp() { _fixture = new Fixture(); _pipelineData = _fixture.Create <PipelineData>(); _pipelineResult = new PipelineResult(); _filter = new Mock <IFulfilmentPipelinesFilter>(); _pipeline1Mock = new Mock <IPipeline <PipelineData, PipelineResult> >(); _pipeline1Mock.Setup(x => x.Name).Returns("Step 1"); _pipeline2Mock = new Mock <IPipeline <PipelineData, PipelineResult> >(); _pipeline2Mock.Setup(x => x.Name).Returns("Step 2"); _pipeline3Mock = new Mock <IPipeline <PipelineData, PipelineResult> >(); _pipeline3Mock.Setup(x => x.Name).Returns("Step 3"); _loggerMock = new Mock <ILogger>(); _pipelineSectorFactory = new Mock <IPipelineFactory>(); _pipelines = new List <IPipeline <PipelineData, PipelineResult> >(); _pipelines.AddRange(new[] { _pipeline1Mock.Object, _pipeline2Mock.Object, _pipeline3Mock.Object }); }
/// <summary> /// Compiles the specified pipeline data. /// </summary> /// <param name="pipelineData">The pipeline data.</param> /// <returns>the lambda lifted closure</returns> public static Func<Tuple<IResolveTypes, object>, object, object, object> Compile(PipelineData pipelineData) { if (!pipelineData.IsClosed) throw new MismatchedClosingTypeDeclarationException(); //// here we roll the composition of function into an y=h(g(f(x))) delegate //// this is a bit more contrived than we ultimately want, but it was more //// entertaining to write it this way for now. var function = CreateExecutor(pipelineData.FunctionList.Dequeue()); while(pipelineData.FunctionList.Count > 0) { var item = CreateExecutor(pipelineData.FunctionList.Dequeue()); var localFunction = function; function = (resolver,name, value) => item(resolver, resolver.Item2, localFunction( resolver, resolver.Item2, value)); } return function; }
public PipelineData Process(PipelineData Input) { if (LWMSTraceListener.EnableConsoleOutput == true) { PipedRoutedWROption option = (PipedRoutedWROption)Input.Options; if (option.PipedRoutedWROperation == PipedRoutedWROperation.WRITE) { Console.Out.Write((string)Input.PrimaryData); } else if (option.PipedRoutedWROperation == PipedRoutedWROperation.WRITELINE) { Console.Out.WriteLine((string)Input.PrimaryData); } else if (option.PipedRoutedWROperation == PipedRoutedWROperation.FLUSH) { Console.Out.Flush(); } else if (option.PipedRoutedWROperation == PipedRoutedWROperation.CLEAR) { Console.Clear(); } else if (LWMSTraceListener.BeautifyConsoleOutput == true) { if (option.PipedRoutedWROperation == PipedRoutedWROperation.FGCOLOR) { Console.ForegroundColor = (ConsoleColor)Input.PrimaryData; } else if (option.PipedRoutedWROperation == PipedRoutedWROperation.BGCOLOR) { Console.BackgroundColor = (ConsoleColor)Input.PrimaryData; } else if (option.PipedRoutedWROperation == PipedRoutedWROperation.RESETCOLOR) { Console.ResetColor(); } } } return(Input); }
public PipelineData Process(PipelineData Input) { HttpListenerRoutedContext context = Input.PrimaryData as HttpListenerRoutedContext; var path0 = context.Request.Url.LocalPath.Substring(1); var path1 = Path.Combine(GlobalConfiguration.GetWebSiteContentRoot(context.PipelineAuth), path0); if (Directory.Exists(path1)) { var DefaultPage = Path.Combine(path1, GlobalConfiguration.GetDefaultPage(context.PipelineAuth)); if (File.Exists(DefaultPage)) { if (path1.EndsWith("htm") || path1.EndsWith("html")) { ProcessContent(context, DefaultPage); (Input.SecondaryData as HttpPipelineArguments).isHandled = true; } } else { } } else { if (File.Exists(path1)) { if (path1.EndsWith("htm") || path1.EndsWith("html")) { ProcessContent(context, path1); (Input.SecondaryData as HttpPipelineArguments).isHandled = true; } } else { } //Console.WriteLine("Directory Not Found."); } return(Input); }
public UriParametersFilter(ICommunicationContext context, IErrorCollector collector) { this.Logger = NullLogger.Instance; this.Errors = collector; this.pipelineData = context.PipelineData; }
public CachingInterceptor(ICommunicationContext context, ICacheProvider cache) { _request = context.Request; _data = context.PipelineData; _cache = cache; }
public AbstractApplicationXWwwFormUrlencodedCodec(ICommunicationContext context, IObjectBinderLocator locator) { _pipelineData = context.PipelineData; _binderLocator = locator; }