add IPluginFeatureConstructor as alternative provider option
This commit is contained in:
5
Pilz.Plugins.Advanced/IPluginFeatureConstructor.cs
Normal file
5
Pilz.Plugins.Advanced/IPluginFeatureConstructor.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Pilz.Plugins.Advanced;
|
||||
|
||||
public interface IPluginFeatureConstructor
|
||||
{
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pilz.Plugins.Advanced;
|
||||
|
||||
@@ -132,6 +133,19 @@ public class PluginFeatureController
|
||||
if (method != null && method.Invoke(null, null) is PluginFeature feature)
|
||||
Register(feature);
|
||||
}
|
||||
else if (type.IsAssignableTo(typeof(IPluginFeatureConstructor)))
|
||||
{
|
||||
if (type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic, [typeof(PluginFeatureController)]) is ConstructorInfo ctor1)
|
||||
{
|
||||
if (ctor1.Invoke([this]) is PluginFeature feature)
|
||||
Register(feature);
|
||||
}
|
||||
else if (type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic, []) is ConstructorInfo ctor)
|
||||
{
|
||||
if (ctor.Invoke([this]) is PluginFeature feature)
|
||||
Register(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user