ReflectionPluginFactory
NexusLabs.Needlr.Injection.Reflection¶
NexusLabs.Needlr.Injection.Reflection.PluginFactories¶
ReflectionPluginFactory Class¶
Plugin factory that uses runtime reflection to scan assemblies for types that implement specified interfaces, are decorated with particular attributes, or meet both criteria. All discovered types are instantiated using their parameterless constructors.
Inheritance System.Object 🡒 ReflectionPluginFactory
Implements NexusLabs.Needlr.IPluginFactory
Remarks¶
This factory uses runtime reflection and is not compatible with NativeAOT or trimming. For AOT scenarios, use the GeneratedPluginFactory from NexusLabs.Needlr.Injection.SourceGen instead.
Methods¶
ReflectionPluginFactory.CreatePluginsFromAssemblies<TPlugin,TAttribute>(IEnumerable<Assembly>) Method¶
Creates instances of plugins of type TPlugin from the provided assemblies that are also decorated with the specified attribute.
public System.Collections.Generic.IEnumerable<TPlugin> CreatePluginsFromAssemblies<TPlugin,TAttribute>(System.Collections.Generic.IEnumerable<System.Reflection.Assembly> assemblies)
where TPlugin : class
where TAttribute : System.Attribute;
Type parameters¶
TPlugin
The plugin interface or base type to search for.
TAttribute
The attribute type to search for in the type hierarchy.
Parameters¶
assemblies System.Collections.Generic.IEnumerable<System.Reflection.Assembly>
A collection of assemblies to scan for plugin types.
Implements CreatePluginsFromAssemblies<TPlugin,TAttribute>(IEnumerable<Assembly>)
Returns¶
System.Collections.Generic.IEnumerable<TPlugin>
An enumerable of instantiated plugins implementing TPlugin and
decorated with TAttribute.
ReflectionPluginFactory.CreatePluginsFromAssemblies<TPlugin>(IEnumerable<Assembly>) Method¶
Creates instances of plugins of type TPlugin from the provided assemblies.
public System.Collections.Generic.IEnumerable<TPlugin> CreatePluginsFromAssemblies<TPlugin>(System.Collections.Generic.IEnumerable<System.Reflection.Assembly> assemblies)
where TPlugin : class;
Type parameters¶
TPlugin
The plugin interface or base type to search for.
Parameters¶
assemblies System.Collections.Generic.IEnumerable<System.Reflection.Assembly>
A collection of assemblies to scan for plugin types.
Implements CreatePluginsFromAssemblies<TPlugin>(IEnumerable<Assembly>)
Returns¶
System.Collections.Generic.IEnumerable<TPlugin>
An enumerable of instantiated plugins implementing TPlugin.
ReflectionPluginFactory.CreatePluginsWithAttributeFromAssemblies<TAttribute>(IEnumerable<Assembly>) Method¶
Creates instances of plugins from the provided assemblies that are decorated with the specified attribute.
public System.Collections.Generic.IEnumerable<object> CreatePluginsWithAttributeFromAssemblies<TAttribute>(System.Collections.Generic.IEnumerable<System.Reflection.Assembly> assemblies)
where TAttribute : System.Attribute;
Type parameters¶
TAttribute
The attribute type to search for in the type hierarchy.
Parameters¶
assemblies System.Collections.Generic.IEnumerable<System.Reflection.Assembly>
A collection of assemblies to scan for plugin types.
Implements CreatePluginsWithAttributeFromAssemblies<TAttribute>(IEnumerable<Assembly>)
Returns¶
System.Collections.Generic.IEnumerable<System.Object>
An enumerable of instantiated plugins decorated with TAttribute.