PipelineNet icon indicating copy to clipboard operation
PipelineNet copied to clipboard

Pipeline persistence

Open adyrotaru opened this issue 1 year ago • 1 comments

Once I define a pipeline, how can I persist it in a file/table and be able to reload it?

adyrotaru avatar Sep 06 '24 06:09 adyrotaru

This is not built-in.

You would need to serialize/deserialize middleware types collection but this is unsafe: https://github.com/dotnet/runtime/issues/31567.

You could make it safer by reading type names from configuration store where you keep your other credentials/API keys/connection strings and validating a string against a whitelist of all known middleware type names (string[] knownMiddlewareTypeNames) before calling Type.GetType method. But you would still introduce a security antipattern to your codebase this way and someone would eventually mess it up.

Having said all this, it would be just:

Type[] middlewareTypes;

var pipeline = new Pipeline<Bitmap>(new ActivatorMiddlewareResolver());

foreach (var middlewareType in middlewareTypes)
{
    pipeline.Add(middlewareType);
}

mariusz96 avatar Sep 06 '24 17:09 mariusz96

As @mariusz96 pointed out, you would have to create your own implementation for that.

ipvalverde avatar Oct 12 '24 15:10 ipvalverde