1.2.0
New features:
Add support for default naming options
Previously, it was possible to set catalog-specific naming options. These options can be used to override the default logic of deciding the plugin's name and version. The latest version adds the option of setting catalog type specific default options.
The use case for this feature is an application which creates catalogs in multiple places. Instead of having to remember to pass catalog options to each new catalog, you can configure the default naming options once, when the application starts.
The following catalog types support this:
- Assembly
- Type
- Folder
- NugetPackage
- NugetFeed
You can configure the naming options like this:
AssemblyPluginCatalogOptions.Defaults.PluginNameOptions = new PluginNameOptions()
{
PluginNameGenerator = (nameOptions, type) => type.FullName + "Modified"
};
You can override the default options when creating a catalog:
AssemblyPluginCatalogOptions.Defaults.PluginNameOptions = new PluginNameOptions()
{
PluginNameGenerator = (nameOptions, type) => type.FullName + "Modified"
};
var options = new AssemblyPluginCatalogOptions()
{
PluginNameOptions = new PluginNameOptions() { PluginNameGenerator = (nameOptions, type) => type.FullName + "Overridden" }
};
var catalog = new AssemblyPluginCatalog(@"..\..\..\..\..\Assemblies\bin\netstandard2.0\TestAssembly1.dll");
var catalog2 = new AssemblyPluginCatalog(@"..\..\..\..\..\Assemblies\bin\netstandard2.0\TestAssembly2.dll", options);
await catalog.Initialize();
await catalog2.Initialize();
var catalog1Plugins = catalog.GetPlugins();
foreach (var plugin in catalog1Plugins)
{
Assert.EndsWith("Modified", plugin.Name);
}
var catalog2Plugins = catalog2.GetPlugins();
foreach (var plugin in catalog2Plugins)
{
Assert.EndsWith("Overridden", plugin.Name);
}