diff --git a/Pilz.Plugins.Advanced/Pilz.Plugins.Advanced.csproj b/Pilz.Plugins.Advanced/Pilz.Plugins.Advanced.csproj
index 46d765a..11249c5 100644
--- a/Pilz.Plugins.Advanced/Pilz.Plugins.Advanced.csproj
+++ b/Pilz.Plugins.Advanced/Pilz.Plugins.Advanced.csproj
@@ -9,7 +9,7 @@
True
- 2.1.0
+ 2.2.0
diff --git a/Pilz.Plugins.Advanced/PluginFeatureController.cs b/Pilz.Plugins.Advanced/PluginFeatureController.cs
index c301a13..2ff7567 100644
--- a/Pilz.Plugins.Advanced/PluginFeatureController.cs
+++ b/Pilz.Plugins.Advanced/PluginFeatureController.cs
@@ -17,14 +17,15 @@ namespace Pilz.Plugins.Advanced
private readonly List features = new();
///
- /// Returns a collection of all registred instances.
+ /// A wrapper of all registred instances.
///
- public IReadOnlyList Features => features.AsReadOnly();
+ public FeatureController Features { get; init; }
///
/// A wrapper for all registred instances.
///
public ModuleController Modules { get; init; }
+
///
/// A wrapper for all registred instances.
///
@@ -32,6 +33,7 @@ namespace Pilz.Plugins.Advanced
public PluginFeatureController()
{
+ Features = new(this);
Functions = new(this);
Modules = new(this);
}
@@ -47,43 +49,64 @@ namespace Pilz.Plugins.Advanced
features.Remove(module);
}
- public class ModuleController
+ public class FeatureController
{
- private readonly PluginFeatureController controller;
+ protected readonly PluginFeatureController controller;
- public ModuleController(PluginFeatureController controller)
+ public FeatureController(PluginFeatureController controller)
{
this.controller = controller;
}
- public IEnumerable GetAll()
+ public virtual IEnumerable GetAll()
{
- return controller.features.OfType();
+ return controller.features.AsReadOnly();
}
- public IEnumerable Get(string moduleType)
+ public virtual IEnumerable Get(string moduleType)
{
- return GetAll().Where(n => n.Type == moduleType);
+ return controller.features.Where(n => n.Type == moduleType);
+ }
+
+ public virtual PluginFeature? GetFirst(string moduleType)
+ {
+ return controller.features.FirstOrDefault(n => n.Type == moduleType);
}
}
- public class FunctionController
+ public class FeatureController : FeatureController where T : PluginFeature
{
- private readonly PluginFeatureController controller;
-
- public FunctionController(PluginFeatureController controller)
+ public FeatureController(PluginFeatureController controller) : base(controller)
{
- this.controller = controller;
}
- public IEnumerable GetAll()
+ public override IEnumerable GetAll()
{
- return controller.features.OfType();
+ return controller.features.OfType();
}
- public IEnumerable Get(string functionType)
+ public override IEnumerable Get(string moduleType)
+ {
+ return GetAll().Where(n => n.Type == moduleType);
+ }
+
+ public override T? GetFirst(string moduleType)
+ {
+ return GetAll().FirstOrDefault(n => n.Type == moduleType);
+ }
+ }
+
+ public class ModuleController : FeatureController
+ {
+ public ModuleController(PluginFeatureController controller) : base(controller)
+ {
+ }
+ }
+
+ public class FunctionController : FeatureController
+ {
+ public FunctionController(PluginFeatureController controller) : base(controller)
{
- return GetAll().Where(n => n.Type == functionType);
}
public void ExecuteAll(string functionType)