Skip to content

Commit

Permalink
Fix README
Browse files Browse the repository at this point in the history
  • Loading branch information
markthiessen committed Mar 28, 2021
1 parent 46e77e0 commit 4f00afa
Showing 1 changed file with 6 additions and 34 deletions.
40 changes: 6 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Or via the .NET Core command line interface:

dotnet add package Pipr

Either commands, from Package Manager Console or .NET Core CLI, will download and install Pipr and all required dependencies.
Either commands, from Package Manager Console or .NET Core CLI, will download
and install Pipr and all required dependencies.

### Usage

Expand Down Expand Up @@ -53,40 +54,10 @@ var result = pipeline.Execute(12);

The in/out of the pipeline can be inferred by the type system as you add steps.

#### Dependency Injection

You can also have Pipr create your objects for you using the IServiceProvider from `Microsoft.Extensions.DependencyInjection` if you specify the type and the inputs and outputs as you build the pipeline and configure on startup.

In Startup.cs:

```
...
serviceCollection.AddTransient<ToStringStep>(); // (example, doesn't have to be Transient lifetime)
serviceCollection.AddTransient<DoublerStep>();
serviceCollection.AddPipr();
...
```

Then create and use pipelines like so:

```
var pipeline = new PipelineBuilder()
.AddStep(PipelineBuilder.UseService<ToStringStep>())
.AddStep(PipelineBuilder.UseService<DoublerStep>())
.AddStep(PipelineBuilder.UseService<DoublerStep>())
.Build();
var result = pipeline.Execute(12);
```
The `PipelineBuilder.UseService<T>()` method doesn't really do anything but return default(T). This just lets us have nicer syntax for configuring without having to pass in all of the in/out types and still use dependency injection.


#### Aborting

Pipeline steps can cancel and abort further processing by calling `context.Cancel()`:
Pipeline steps can cancel and abort further processing by calling
`context.Cancel()`:

For example

Expand All @@ -101,4 +72,5 @@ public class CancellingStep : IStep<string, string>
}
```

If a step cancels further processing, no following steps will run, and the pipeline return value will be the default value for the return type.
If a step cancels further processing, no following steps will run, and the
pipeline return value will be the default value for the return type.

0 comments on commit 4f00afa

Please sign in to comment.