Mvp24Hours.Infrastructure.Pipe
3.1.101
See the version list below for details.
dotnet add package Mvp24Hours.Infrastructure.Pipe --version 3.1.101
NuGet\Install-Package Mvp24Hours.Infrastructure.Pipe -Version 3.1.101
<PackageReference Include="Mvp24Hours.Infrastructure.Pipe" Version="3.1.101" />
paket add Mvp24Hours.Infrastructure.Pipe --version 3.1.101
#r "nuget: Mvp24Hours.Infrastructure.Pipe, 3.1.101"
// Install Mvp24Hours.Infrastructure.Pipe as a Cake Addin
#addin nuget:?package=Mvp24Hours.Infrastructure.Pipe&version=3.1.101
// Install Mvp24Hours.Infrastructure.Pipe as a Cake Tool
#tool nuget:?package=Mvp24Hours.Infrastructure.Pipe&version=3.1.101
Pipeline (Pipe and Filters Pattern)
It is a design pattern that represents a tube with several operations (filters), executed sequentially, in order to travel, integrate and/or handle a package/message.
Prerequisites (Not Required)
Add a configuration file to the project named "appsettings.json", as below:
{
"Mvp24Hours": {
"Pipe": {
"Operation": {
"FileLog": {
"Enable": false,
"Path": ""
},
"FileToken": {
"Enable": false,
"Path": ""
}
}
}
}
}
Installation
/// Package Manager Console >
Install-Package Mvp24Hours.Infrastructure.Pipe
Configuration
/// Startup.cs
services.AddMvp24HoursPipeline();
Usage Example
var pipeline = ServiceProviderHelper.GetService<IPipeline>();
// run pipeline
pipeline.Execute();
// run with package/message
var message = "Parameter received.".ToMessage();
pipeline.Execute(message);
// get package after run
pipeline.GetMessage();
// add IOperation operation/filter
pipeline.Add<MyOperation>();
// add operation/filter as action
pipeline.Add(_ =>
{
Trace.WriteLine("Test 1");
});
// package interaction actions by type
pipeline.Add(input =>
{
string param = input.GetContent<string>(); // get content
input.AddContent($"Test 1 - {param}"); // add content
if (input.HasContent<string>()) {} // check for content
input.SetLock(); // block package/message
input.SetFailure(); // log failure
});
// packet interaction actions by key
pipeline.Add(input =>
{
string param = input.GetContent<string>("key"); // get content with key
input.AddContent("key", $"Test 1 - {param}"); // add content with key
if (input.HasContent("key")) {} // check for content with key
input.SetLock(); // block package/message
input.SetFailure(); // log failure
});
// adding interceptors
pipeline.AddInterceptors(_ =>
{
// ... commands
}, PipelineInterceptorType.PostOperation); // PostOperation, PreOperation, Locked, Faulty, FirstOperation, LastOperation
// adding conditional interceptors
pipeline.AddInterceptors(_ =>
{
// ... commands
},
input =>
{
return input.HasContent<int>();
});
// adding interceptors as events
pipeline.AddInterceptors((input, e) =>
{
// ... commands
}, PipelineInterceptorType.PostOperation); // PostOperation, PreOperation, Locked, Faulty, FirstOperation, LastOperation
// adding conditional interceptors as events
pipeline.AddInterceptors((input, e) =>
{
// ... commands
},
input =>
{
return input.HasContent<int>();s
});
Creating Operations
To create an operation, simply implement an IOperation or an OperationBase:
/// MyOperation.cs
public class MyOperation : OperationBase
{
public override bool IsRequired => false; // indicates if the operation will execute even with the locked package
public override IPipelineMessage Execute(IPipelineMessage input)
{
// perform action
return input;
}
}
// add to pipeline
pipeline.Add<MyOperation>();
Creating Builders
You can add dynamic operations using a build pattern (builder). Generally, we use it when implementing Ports And Adapters architectures where we plug in adapters that implement specialized rules.
/// ..my-core/contract/builders/IProductCategoryListBuilder.cs
public interface IProductCategoryListBuilder : IPipelineBuilder { }
/// ..my-adapter-application/application/builders/ProductCategoryListBuilder.cs
public class ProductCategoryListBuilder : IProductCategoryListBuilder
{
public IPipelineAsync Builder(IPipelineAsync pipeline)
{
return pipeline
.Add<ProductCategoryFileOperation>()
.Add<ProductCategoryResponseMapperOperation>();
}
}
/// Startup.cs
services.AddScoped<IProductCategoryListBuilder, ProductCategoryListBuilder>();
/// ..my-application/application/services/MyService.cs /MyMethod
var pipeline = ServiceProviderHelper.GetService<IPipeline>();
var builder = ServiceProviderHelper.GetService<IProductCategoryListBuilder>();
builder.Builder(pipeline);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Mvp24Hours.Core (>= 3.1.101)
- Mvp24Hours.Infrastructure (>= 3.1.101)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.3.261 | 102 | 3/26/2024 |
8.2.102 | 148 | 2/9/2024 |
8.2.101 | 83 | 2/7/2024 |
4.1.191 | 162 | 1/19/2024 |
4.1.181 | 69 | 1/19/2024 |
3.12.262 | 135 | 12/26/2023 |
3.12.261 | 90 | 12/26/2023 |
3.12.221 | 104 | 12/22/2023 |
3.12.151 | 105 | 12/17/2023 |
3.6.221 | 1,133 | 6/22/2022 |
3.4.111 | 413 | 4/11/2022 |
3.2.241 | 451 | 2/24/2022 |
3.2.171 | 408 | 2/17/2022 |
3.2.151 | 388 | 2/15/2022 |
3.2.142 | 389 | 2/14/2022 |
3.2.141 | 382 | 2/14/2022 |
3.2.21 | 391 | 2/2/2022 |
3.1.243 | 401 | 1/25/2022 |
3.1.242 | 406 | 1/24/2022 |
3.1.241 | 374 | 1/24/2022 |
3.1.221 | 367 | 1/22/2022 |
3.1.201 | 386 | 1/20/2022 |
3.1.101 | 386 | 1/10/2022 |
2.12.291 | 233 | 12/29/2021 |
2.12.102 | 255 | 12/10/2021 |
2.12.101 | 255 | 12/10/2021 |
2.12.71 | 240 | 12/7/2021 |
2.11.241 | 4,256 | 11/24/2021 |