public void RequestPipeline() { var settings = TestClient.CreateSettings(); /** When calling Request(Async) on Transport the whole coordination of the request is deferred to a new instance in a `using` block. */ var pipeline = new RequestPipeline(settings, DateTimeProvider.Default, new MemoryStreamFactory(), new SearchRequestParameters()); pipeline.GetType().Should().Implement<IDisposable>(); /** However the transport does not instantiate RequestPipeline directly, it uses a pluggable `IRequestPipelineFactory`*/ var requestPipelineFactory = new RequestPipelineFactory(); var requestPipeline = requestPipelineFactory.Create(settings, DateTimeProvider.Default, new MemoryStreamFactory(), new SearchRequestParameters()); requestPipeline.Should().BeOfType<RequestPipeline>(); requestPipeline.GetType().Should().Implement<IDisposable>(); /** which can be passed to the transport when instantiating a client */ var transport = new Transport<ConnectionSettings>(settings, requestPipelineFactory, DateTimeProvider.Default, new MemoryStreamFactory()); /** this allows you to have requests executed on your own custom request pipeline */ }
public void RequestPipeline() { var settings = TestClient.CreateSettings(); /** When calling `Request()` or `RequestAsync()` on an `ITransport`, * the whole coordination of the request is deferred to a new instance in a `using` block. */ var pipeline = new RequestPipeline( settings, DateTimeProvider.Default, new MemoryStreamFactory(), new SearchRequestParameters()); pipeline.GetType().Should().Implement<IDisposable>(); /** An `ITransport` does not instantiate a `RequestPipeline` directly; it uses a pluggable `IRequestPipelineFactory` * to create it */ var requestPipelineFactory = new RequestPipelineFactory(); var requestPipeline = requestPipelineFactory.Create( settings, DateTimeProvider.Default, //<1> An <<date-time-providers,`IDateTimeProvider` implementation>> new MemoryStreamFactory(), new SearchRequestParameters()); requestPipeline.Should().BeOfType<RequestPipeline>(); requestPipeline.GetType().Should().Implement<IDisposable>(); /** You can pass your own `IRequestPipeline` implementation to the Transport when instantiating a client, * allowing you to have requests executed on your own custom request pipeline */ var transport = new Transport<ConnectionSettings>( settings, requestPipelineFactory, DateTimeProvider.Default, new MemoryStreamFactory()); }