add optional namespace filter
This commit is contained in:
@@ -62,7 +62,7 @@ public class PluginFeatureController
|
||||
/// Registers all features found in the currently executing Assembly via <see cref="IPluginFeatureProvider"/>, <see cref="IPluginFeatureProvider{T}"/> and <see cref="IPluginFeaturesProvider"/>.
|
||||
/// <para><b>Note:</b><br/>Explicit implementations of <see cref="IPluginFeatureProvider{T}.Instance"/> can not be detected. For this case just implement <see cref="IPluginFeatureProvider.Instance"/> instead.</para>
|
||||
/// </summary>
|
||||
public void RegisterAllOwn()
|
||||
public void RegisterAllOwn(string? @namespace = null)
|
||||
{
|
||||
RegisterAll(Assembly.GetCallingAssembly());
|
||||
}
|
||||
@@ -71,8 +71,9 @@ public class PluginFeatureController
|
||||
/// Registers all features found in the given <see cref="Assembly[]"/> via <see cref="IPluginFeatureProvider"/>, <see cref="IPluginFeatureProvider{T}"/> and <see cref="IPluginFeaturesProvider"/>.
|
||||
/// <para><b>Note:</b><br/>Explicit implementations of <see cref="IPluginFeatureProvider{T}.Instance"/> can not be detected. For this case just implement <see cref="IPluginFeatureProvider.Instance"/> instead.</para>
|
||||
/// </summary>
|
||||
/// <param name="assemblies"></param>
|
||||
public void RegisterAll(Assembly[] assemblies)
|
||||
/// <param name="assemblies">The assemblies to query for types.</param>
|
||||
/// <param name="namespace">If not null, only types within the given namespace will be registered.</param>
|
||||
public void RegisterAll(Assembly[] assemblies, string? @namespace = null)
|
||||
{
|
||||
foreach (var assembly in assemblies)
|
||||
RegisterAll(assembly);
|
||||
@@ -82,8 +83,9 @@ public class PluginFeatureController
|
||||
/// Registers all features found in the given <see cref="Assembly"/> via <see cref="IPluginFeatureProvider"/>, <see cref="IPluginFeatureProvider{T}"/> and <see cref="IPluginFeaturesProvider"/>.
|
||||
/// <para><b>Note:</b><br/>Explicit implementations of <see cref="IPluginFeatureProvider{T}.Instance"/> can not be detected. For this case just implement <see cref="IPluginFeatureProvider.Instance"/> instead.</para>
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
public void RegisterAll(Assembly assembly)
|
||||
/// <param name="assembly">The assembly to query for types.</param>
|
||||
/// <param name="namespace">If not null, only types within the given namespace will be registered.</param>
|
||||
public void RegisterAll(Assembly assembly, string? @namespace = null)
|
||||
{
|
||||
RegisterAll(assembly.GetTypes());
|
||||
}
|
||||
@@ -92,8 +94,9 @@ public class PluginFeatureController
|
||||
/// Registers all features found from the given <see cref="Type[]"/> via <see cref="IPluginFeatureProvider"/>, <see cref="IPluginFeatureProvider{T}"/> and <see cref="IPluginFeaturesProvider"/>.
|
||||
/// <para><b>Note:</b><br/>Explicit implementations of <see cref="IPluginFeatureProvider{T}.Instance"/> can not be detected. For this case just implement <see cref="IPluginFeatureProvider.Instance"/> instead.</para>
|
||||
/// </summary>
|
||||
/// <param name="types"></param>
|
||||
public void RegisterAll(Type[] types)
|
||||
/// <param name="types">The types to query for providers.</param>
|
||||
/// <param name="namespace">If not null, the types will only be processed if they're within the given namespace.</param>
|
||||
public void RegisterAll(Type[] types, string? @namespace = null)
|
||||
{
|
||||
foreach (var type in types)
|
||||
RegisterAll(type);
|
||||
@@ -103,9 +106,13 @@ public class PluginFeatureController
|
||||
/// Registers all features found from the given <see cref="Type"/> via <see cref="IPluginFeatureProvider"/>, <see cref="IPluginFeatureProvider{T}"/> and <see cref="IPluginFeaturesProvider"/>.
|
||||
/// <para><b>Note:</b><br/>Explicit implementations of <see cref="IPluginFeatureProvider{T}.Instance"/> can not be detected. For this case just implement <see cref="IPluginFeatureProvider.Instance"/> instead.</para>
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
public void RegisterAll(Type type)
|
||||
/// <param name="type">The type to query for providers.</param>
|
||||
/// <param name="namespace">If not null, the type will only be processed if it's within the given namespace.</param>
|
||||
public void RegisterAll(Type type, string? @namespace = null)
|
||||
{
|
||||
if (@namespace != null && type.Namespace != null && type.Namespace != @namespace && !type.Namespace.StartsWith(@namespace + "."))
|
||||
return;
|
||||
|
||||
if (type.IsAssignableTo(typeof(IPluginFeaturesProvider)))
|
||||
{
|
||||
var methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
|
||||
Reference in New Issue
Block a user