add feature identifier
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
<Version>2.3.0</Version>
|
<Version>2.4.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -9,19 +9,47 @@ namespace Pilz.Plugins.Advanced
|
|||||||
{
|
{
|
||||||
public abstract class PluginFeature
|
public abstract class PluginFeature
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The type of the feature defines where the feature get integrated.
|
||||||
|
/// </summary>
|
||||||
public string Type { get; init; }
|
public string Type { get; init; }
|
||||||
|
/// <summary>
|
||||||
|
/// The identifier of the feature should be uniquie for the current <see cref="Type"/>.
|
||||||
|
/// It defines a feature within a type.
|
||||||
|
/// </summary>
|
||||||
|
public string Identifier { get; init; }
|
||||||
|
/// <summary>
|
||||||
|
/// The full identifier of the feature should be uniquie and is the combination of <see cref="Type"/> and <see cref="Identifier"/>.
|
||||||
|
/// It defines a feature across all types.
|
||||||
|
/// </summary>
|
||||||
|
public string FullIdentifier => GetFullIdentifier(Type, Identifier);
|
||||||
|
/// <summary>
|
||||||
|
/// The (display) name of the feature.
|
||||||
|
/// </summary>
|
||||||
public virtual string? Name { get; init; }
|
public virtual string? Name { get; init; }
|
||||||
|
/// <summary>
|
||||||
|
/// The symbol for the feature.
|
||||||
|
/// </summary>
|
||||||
public virtual RadSvgImage? Icon { get; set; }
|
public virtual RadSvgImage? Icon { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Defines if the feature is enabled/visible.
|
||||||
|
/// </summary>
|
||||||
public virtual bool Enabled { get; set; } = true;
|
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}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Telerik.Pdf;
|
||||||
|
using Telerik.WinControls;
|
||||||
|
|
||||||
namespace Pilz.Plugins.Advanced
|
namespace Pilz.Plugins.Advanced
|
||||||
{
|
{
|
||||||
@@ -79,14 +81,24 @@ namespace Pilz.Plugins.Advanced
|
|||||||
return controller.features.AsReadOnly();
|
return controller.features.AsReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IEnumerable<PluginFeature> Get(string moduleType)
|
public virtual IEnumerable<PluginFeature> 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)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ namespace Pilz.Plugins.Advanced
|
|||||||
{
|
{
|
||||||
public abstract class PluginFunction : PluginFeature
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Pilz.Plugins.Advanced
|
|||||||
public bool Visible { get; set; } = true;
|
public bool Visible { get; set; } = true;
|
||||||
public bool AllowEmbedding { 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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user