https://github.com/subethasensomatic/pipeline
Asynchronous ASP.NET Core like pipeline implementation
https://github.com/subethasensomatic/pipeline
asynchronous csharp dotnet-core patterns pipeline
Last synced: 3 months ago
JSON representation
Asynchronous ASP.NET Core like pipeline implementation
- Host: GitHub
- URL: https://github.com/subethasensomatic/pipeline
- Owner: SubEthaSensOMatic
- License: mit
- Created: 2018-07-10T11:28:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T18:27:26.000Z (almost 8 years ago)
- Last Synced: 2026-01-01T04:22:38.815Z (7 months ago)
- Topics: asynchronous, csharp, dotnet-core, patterns, pipeline
- Language: C#
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pipeline
Asynchronous ASP.NET Core like pipeline implementation
### Usage
Create a context Class ...
```csharp
public class MyPipelineContext
{
public string SharedInformationBetweenItems { get; set; }
}
```
Create items for your pipeline ...
```csharp
public class MyPipelineItem: IPipelineItem
{
public async Task run(MyPipelineContext ctx, Func next)
{
await next();
Console.WriteLine(ctx.SharedInformationBetweenItems);
}
}
```
Configure and run your pipeline ...
```csharp
...
// without dependency injection
// var builder = new PipelineBuilder();
// or with dependency injection
var builder = new PipelineBuilder(itemType => container.Resolve(itemType));
// Add delegate item to pipeline
builder.Use(async (ctx, next) => {
ctx.SharedInformationBetweenItems = "Some text...";
// don't forget to call
await next();
});
// Use item object
builder.Use();
// Build pipeline ...
var pipeline = builder.BuildPipeline();
// ... and run
var myContext = new MyPipelineContext();
await pipeline(myContext);
// ... run again with new context
myContext = new MyPipelineContext();
await pipeline(myContext);
...
```