using System;namespace Ao.Middleware.Samples
{internalclassProgram{staticvoidMain(string[]args){varbuilder=newMiddlewareBuilder<Sum>();//Define a middleware builderfor(inti=0;i<10;i++){
builder.Use(x => x.Count++);//add middleware}varhandler= builder.Build();//Build an pipelinevars=new Sum();//Define context
handler(s).GetAwaiter().GetResult();//Execute
Console.WriteLine(s.Count);//Result is 10}}publicclassSum{publicintCount{get;set;}}}
In sync mode
using System;namespace Ao.Middleware.Samples
{internalclassProgram{staticvoidMain(string[]args){varbuilder=newSyncMiddlewareBuilder<Sum>();//Define a middleware builderfor(inti=0;i<10;i++){
builder.Use(x => x.Count++);//add middleware}varhandler= builder.Build();//Build an pipelinevars=new Sum();//Define context
handler(s)//Execute
Console.WriteLine(s.Count);//Result is 10}}publicclassSum{publicintCount{get;set;}}}