diff --git a/Pilz.Plugins.Advanced/Pilz.Plugins.Advanced.csproj b/Pilz.Plugins.Advanced/Pilz.Plugins.Advanced.csproj index 43b75ba..d86b090 100644 --- a/Pilz.Plugins.Advanced/Pilz.Plugins.Advanced.csproj +++ b/Pilz.Plugins.Advanced/Pilz.Plugins.Advanced.csproj @@ -9,7 +9,7 @@ True - 2.3.0 + 2.4.0 diff --git a/Pilz.Plugins.Advanced/PluginFeature.cs b/Pilz.Plugins.Advanced/PluginFeature.cs index 4864206..87ce087 100644 --- a/Pilz.Plugins.Advanced/PluginFeature.cs +++ b/Pilz.Plugins.Advanced/PluginFeature.cs @@ -9,19 +9,47 @@ namespace Pilz.Plugins.Advanced { public abstract class PluginFeature { + /// + /// The type of the feature defines where the feature get integrated. + /// public string Type { get; init; } + /// + /// The identifier of the feature should be uniquie for the current . + /// It defines a feature within a type. + /// + public string Identifier { get; init; } + /// + /// The full identifier of the feature should be uniquie and is the combination of and . + /// It defines a feature across all types. + /// + public string FullIdentifier => GetFullIdentifier(Type, Identifier); + /// + /// The (display) name of the feature. + /// public virtual string? Name { get; init; } + /// + /// The symbol for the feature. + /// public virtual RadSvgImage? Icon { get; set; } + /// + /// Defines if the feature is enabled/visible. + /// public virtual bool Enabled { get; set; } = true; - protected PluginFeature(string functionType) + protected PluginFeature(string featureType, string identifier) { - Type = functionType; + Identifier = identifier; + Type = featureType; } - protected PluginFeature(string functionType, string? functionName) : this(functionType) + protected PluginFeature(string featureType, string featureIdentifier, string? featureName) : this(featureType, featureIdentifier) { - Name = functionName; + Name = featureName; + } + + public static string GetFullIdentifier(string featureType, string identifier) + { + return $"{featureType}:{identifier}"; } } } diff --git a/Pilz.Plugins.Advanced/PluginFeatureController.cs b/Pilz.Plugins.Advanced/PluginFeatureController.cs index 3408aa9..b41b3ea 100644 --- a/Pilz.Plugins.Advanced/PluginFeatureController.cs +++ b/Pilz.Plugins.Advanced/PluginFeatureController.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using Telerik.Pdf; +using Telerik.WinControls; namespace Pilz.Plugins.Advanced { @@ -79,14 +81,24 @@ namespace Pilz.Plugins.Advanced return controller.features.AsReadOnly(); } - public virtual IEnumerable Get(string moduleType) + public virtual IEnumerable Get(string featureType) { - return controller.features.Where(n => n.Type == moduleType); + return controller.features.Where(n => n.Type == featureType); } - public virtual PluginFeature? GetFirst(string moduleType) + public virtual PluginFeature? GetFirst(string featureType) { - return controller.features.FirstOrDefault(n => n.Type == moduleType); + return controller.features.FirstOrDefault(n => n.Type == featureType); + } + + public virtual PluginFeature? GetByIdentifier(string fullIdentifier) + { + return controller.features.FirstOrDefault(n => n.FullIdentifier == fullIdentifier); + } + + public virtual PluginFeature? GetByIdentifier(string featureType, string identifier) + { + return controller.features.FirstOrDefault(n => n.Type == featureType && n.Identifier == identifier); } } @@ -108,7 +120,17 @@ namespace Pilz.Plugins.Advanced public override T? GetFirst(string moduleType) { - return GetAll().FirstOrDefault(n => n.Type == moduleType); + return base.GetFirst(moduleType) as T; + } + + public override T? GetByIdentifier(string fullIdentifier) + { + return base.GetByIdentifier(fullIdentifier) as T; + } + + public override T? GetByIdentifier(string featureType, string identifier) + { + return base.GetByIdentifier(featureType, identifier) as T; } } diff --git a/Pilz.Plugins.Advanced/PluginFunction.cs b/Pilz.Plugins.Advanced/PluginFunction.cs index 5bc6953..b8f6629 100644 --- a/Pilz.Plugins.Advanced/PluginFunction.cs +++ b/Pilz.Plugins.Advanced/PluginFunction.cs @@ -9,11 +9,11 @@ namespace Pilz.Plugins.Advanced { public abstract class PluginFunction : PluginFeature { - protected PluginFunction(string functionType) : base(functionType) + protected PluginFunction(string functionType, string functionIdentifier) : base(functionType, functionIdentifier) { } - protected PluginFunction(string functionType, string? functionName) : base(functionType, functionName) + protected PluginFunction(string functionType, string functionIdentifier, string? functionName) : base(functionType, functionIdentifier, functionName) { } diff --git a/Pilz.Plugins.Advanced/PluginModule.cs b/Pilz.Plugins.Advanced/PluginModule.cs index 57eb772..bb1b171 100644 --- a/Pilz.Plugins.Advanced/PluginModule.cs +++ b/Pilz.Plugins.Advanced/PluginModule.cs @@ -18,7 +18,7 @@ namespace Pilz.Plugins.Advanced public bool Visible { get; set; } = true; public bool AllowEmbedding { get; set; } = true; - protected PluginModule(string moduleType, string moduleName) : base(moduleType, moduleName) + protected PluginModule(string moduleType, string moduleIdentifier, string moduleName) : base(moduleType, moduleIdentifier, moduleName) { }