Skip to content

Instantly share code, notes, and snippets.

@arialdomartini
Created February 15, 2020 13:24
Show Gist options
  • Save arialdomartini/fa06f8f71af9c578e7f93b45382cae87 to your computer and use it in GitHub Desktop.
Save arialdomartini/fa06f8f71af9c578e7f93b45382cae87 to your computer and use it in GitHub Desktop.
internal class MyModule : Module
{
readonly SourceSettings[] _settings =
{
new SourceSettings {FTPServerAddress = "ftp1.server1.lab", Filter = "ALL"},
new SourceSettings {FTPServerAddress = "ftp2.server2.lab", Filter = "pdf;docx"},
new SourceSettings {FTPServerAddress = "ftp3.server3.lab", Filter = "pdf"}
};
protected override void Load(ContainerBuilder builder)
{
foreach (var sourceSettings in _settings)
{
builder
.Register(c => new FTPDocumentSource(sourceSettings.FTPServerAddress))
.Named<IDocumentSource>(sourceSettings.Filter != "ALL" ? "do-not-decorate" : "decorate");
builder.RegisterDecorator<IDocumentSource>((c, inner) => new DocumentSourceFilteringDecorator(inner), fromKey: "decorate");
}
builder.RegisterType<AggregatedDocumentSource>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment