public void set_should_add_plugin() { var args = new ServiceArguments(); var plugin = new Plugin(); args.Has(typeof(Plugin)).ShouldBeFalse(); args.Set(typeof(Plugin), plugin); args.Has(typeof(Plugin)).ShouldBeTrue(); }
public DoNext Filter(ServiceArguments arguments) { if (arguments.Has(typeof(Latch))) { return(DoNext.Stop); } var request = arguments.Get <IHttpRequest>(); if (!request.HasHeader(HttpRequestHeaders.AcceptEncoding)) { return(DoNext.Continue); } var acceptEncoding = request .GetSingleHeader(HttpRequestHeaders.AcceptEncoding); var encoding = _encoders.MatchFor(acceptEncoding); var writer = arguments.Get <IHttpResponse>(); writer.AppendHeader(HttpRequestHeaders.ContentEncoding, encoding.MatchingEncoding.Value); writer.UseEncoding(encoding); arguments.Set(typeof(Latch), new Latch()); return(DoNext.Continue); }
public void Invoke(ServiceArguments arguments, IDictionary <string, object> routeValues, IRequestCompletion requestCompletion) { var currentChain = new CurrentChain(_chain, routeValues); arguments.Set(typeof(ICurrentChain), currentChain); arguments.Set(typeof(IRequestCompletion), requestCompletion); if (arguments.Has(typeof(IChainExecutionLog))) { arguments.Get <IChainExecutionLog>().RootChain = _chain; } if (_chain.Filters.Any(filter => filter.Filter(arguments) == DoNext.Stop)) { return; } IActionBehavior behavior = null; if (arguments.Has(typeof(IChainExecutionLog))) { arguments.Get <IChainExecutionLog>().Trace("Building the Behaviors", () => { behavior = _factory.BuildBehavior(arguments, _chain.UniqueId); }); } else { behavior = _factory.BuildBehavior(arguments, _chain.UniqueId); } requestCompletion.WhenCompleteDo(x => { var disposable = behavior as IDisposable; if (disposable != null) { disposable.Dispose(); } }); behavior.Invoke(); }
public void Invoke(ServiceArguments arguments, IDictionary<string, object> routeValues, IRequestCompletion requestCompletion) { var currentChain = new CurrentChain(_chain, routeValues); arguments.Set(typeof(ICurrentChain), currentChain); arguments.Set(typeof(IRequestCompletion), requestCompletion); if (arguments.Has(typeof (IChainExecutionLog))) { arguments.Get<IChainExecutionLog>().RootChain = _chain; } if (_chain.Filters.Any(filter => filter.Filter(arguments) == DoNext.Stop)) { return; } IActionBehavior behavior = null; if (arguments.Has(typeof (IChainExecutionLog))) { arguments.Get<IChainExecutionLog>().Trace("Building the Behaviors", () => { behavior = _factory.BuildBehavior(arguments, _chain.UniqueId); }); } else { behavior = _factory.BuildBehavior(arguments, _chain.UniqueId); } requestCompletion.WhenCompleteDo(x => { var disposable = behavior as IDisposable; if (disposable != null) { disposable.Dispose(); } }); behavior.Invoke(); }
public IActionBehavior BuildBehavior(ServiceArguments arguments, Guid behaviorId) { var diagnostics = _container.Get<DiagnosticBehavior>(); var writer = arguments.Has(typeof(IOutputWriter)) ? arguments.Get<IOutputWriter>() : _container.Get<IOutputWriter>(); var report = _container.Get<IDebugReport>(); arguments.Set(typeof(IOutputWriter), new RecordingOutputWriter(report, writer)); var behavior = _inner.BuildBehavior(arguments, behaviorId); diagnostics.Inner = behavior; return diagnostics; }
public DoNext Filter(ServiceArguments arguments) { if (arguments.Has(typeof(Latch))) return DoNext.Stop; arguments .Get<IRequestData>() .ValuesFor(RequestDataSource.Header) .Value(HttpRequestHeaders.AcceptEncoding, x => { var encoding = _encoders.MatchFor(x.RawValue as string); var writer = arguments.Get<IHttpWriter>(); writer.AppendHeader(HttpRequestHeaders.ContentEncoding, encoding.MatchingEncoding.Value); writer.UseEncoding(encoding); }); arguments.Set(typeof(Latch), new Latch()); return DoNext.Continue; }
public DoNext Filter(ServiceArguments arguments) { if (arguments.Has(typeof (Latch))) return DoNext.Stop; var request = arguments.Get<IHttpRequest>(); if (!request.HasHeader(HttpRequestHeaders.AcceptEncoding)) return DoNext.Continue; var acceptEncoding = request .GetSingleHeader(HttpRequestHeaders.AcceptEncoding); var encoding = _encoders.MatchFor(acceptEncoding); var writer = arguments.Get<IHttpResponse>(); writer.AppendHeader(HttpRequestHeaders.ContentEncoding, encoding.MatchingEncoding.Value); writer.UseEncoding(encoding); arguments.Set(typeof (Latch), new Latch()); return DoNext.Continue; }
public DoNext Filter(ServiceArguments arguments) { if (arguments.Has(typeof(Latch))) { return(DoNext.Stop); } arguments .Get <IRequestData>() .ValuesFor(RequestDataSource.Header) .Value(HttpRequestHeaders.AcceptEncoding, x => { var encoding = _encoders.MatchFor(x.RawValue as string); var writer = arguments.Get <IHttpWriter>(); writer.AppendHeader(HttpRequestHeaders.ContentEncoding, encoding.MatchingEncoding.Value); writer.UseEncoding(encoding); }); arguments.Set(typeof(Latch), new Latch()); return(DoNext.Continue); }