-
Notifications
You must be signed in to change notification settings - Fork 7
Home
A cross-platform library supporting .NET 4.6 and netstandard2.0
, PipelineFramework allows you to construct complex linear workflows out a set of components you create.
All component configuration settings are passed into the pipelines using IDictionary<string, IDictionary<string, string>>
constructor argument. This essentially represents a dictionary of key value pairs for each component by registered component name. For example:
var components = new Dictionary<string, IPipelineComponent>
{
{typeof(FooComponent).Name, new FooComponent()},
{typeof(DelayComponent).Name, new DelayComponent()},
{typeof(BarComponent).Name, new BarComponent()},
};
var resolver = new DictionaryPipelineComponentResolver(components);
var settings = new Dictionary<string, IDictionary<string, string>>
{
{typeof(DelayComponent).Name, new Dictionary<string, string>
{
{"DelayTimeSpan", "00:00:10"}
}}
};
var order = new List<Type>
{
typeof(FooComponent), typeof(DelayComponent), typeof(BarComponent)
};
var pipeline = new AsyncPipeline<ExamplePipelinePayload>(resolver, order, settings);
When the DelayComponent above is resolved, it will locate its configuration in the settings argument by name. The framework will then automatically call void Initialize(string name, IDictionary<string, string> settings)
from the IPipelineComponent
interface.
Initialize can be overridden to provide custom component initialization. For example:
private TimeSpan _delay;
public override void Initialize(string name, IDictionary<string, string> settings)
{
base.Initialize(name, settings);
_delay = Settings.GetSettingValue("DelayTimeSpan", TimeSpan.FromSeconds(5), false);
}