.Net plugin framework that allows you to determine the order of plugins (including encoded plugins)

[I read the previous posts about MEF vs MAF vs DI, etc., they do not help me with my specific problem]

I want to write a .Net application (possibly a console or Windoes service) that will be extensible. This is a night / schedule application for retrieving data from a database, doing something with it and then outputting it (or transferring it to another system).

I am not sure what the best way to define this process is for plugins. Components:

  • The task is to determine the actual task containing the plugin definitions and a flag based on events at startup (EOD, EOW, EOM)
  • Source - data source (the task will have one or many sources), it can be an SQL query / stored proc, a web service or, possibly, a file. I see this outputting data.
  • PostProcess - the processing that should be performed on the Source output (the task will have few steps after the process), it may be an aggregator or some specific processing). This will get the data set (containing the data table from the previous step). They must be executed in a specific order due to dependencies.
  • Target - the end result (also one for many), it can be an SQL statement / stored process, patented data loading, email, an output file or a web service.

, , , , , ( ) .

MEF, MAF, DI . , , -?

MEF, , ( , , PostProcess ), config. , MEF Primatives Type Catalogs , , , . MEF?

+3
3

MEF . , , MEF , ! MEF , . . , ( MEF)

[Export(typeof(ITask))]
[ExportMetadata("Requires", "source1")]
public class Task1: ITask
{
    ...
}

MEF . - , . . :

:

public interface IMainApp
{
    ConfigClass Config { get; set; } 
}

Host App:

[Export(typeof(IMainApp))]
public class Host : IMainApp
{
    public Host()
    { /* Compose parts here..? */ }

    public ConfigClass Config { get; set; }  

    [Import(typeof(IModule))]
    public List<IModule> LoadedModules { get; set; }
}

:

[Export(typeof(IModule))]
public class Module : IModule
{        
    public Module() { }

    [Import(typeof(IMainApp))]
    public IMainApp Host { get; set; } 

    public void DoSomething()
    {
        Host.Config... // use config here
    }
}
+3

, , . MEF , , . , MEF Contrib .

+1

Mono.Addins. ( ), . , .

, :

[Extension (Id="MySource")]
class MySource: ISource
{
  ...
}

:

<Extension path="/MyApp/Tasks">
    <Task id="someTask">
        <Source sourceId="MySource" />
        <Target targetId="MyTarget" />
    </Task>
    ...
</Extension>
+1
source

Source: https://habr.com/ru/post/1763378/


All Articles