PluginFeature
This commit is contained in:
@@ -7,59 +7,41 @@ using Telerik.WinControls;
|
||||
|
||||
namespace Pilz.Plugins.Advanced
|
||||
{
|
||||
public abstract class PluginFunction
|
||||
public abstract class PluginFunction : PluginFeature
|
||||
{
|
||||
public string Type { get; init; }
|
||||
public string? Name { get; init; }
|
||||
public RadSvgImage? Icon { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
protected PluginFunction(string functionType)
|
||||
protected PluginFunction(string functionType) : base(functionType)
|
||||
{
|
||||
Type = functionType;
|
||||
}
|
||||
|
||||
protected PluginFunction(string functionType, string functionName) : this(functionType)
|
||||
protected PluginFunction(string functionType, string? functionName) : base(functionType, functionName)
|
||||
{
|
||||
Name = functionName;
|
||||
}
|
||||
|
||||
public object? Execute()
|
||||
public virtual object? Execute()
|
||||
{
|
||||
return Execute((PluginFunctionParameter?)null);
|
||||
}
|
||||
|
||||
public T? Execute<T>(params object?[]? @params)
|
||||
public virtual T? Execute<T>(params object?[]? @params)
|
||||
{
|
||||
return Execute<T>(new PluginFunctionSimpleParamter(@params));
|
||||
}
|
||||
|
||||
public object? Execute(params object?[]? @params)
|
||||
public virtual object? Execute(params object?[]? @params)
|
||||
{
|
||||
return Execute(new PluginFunctionSimpleParamter(@params));
|
||||
}
|
||||
|
||||
public T? Execute<T>(PluginFunctionSimpleParamter? @params)
|
||||
public virtual T? Execute<T>(PluginFunctionSimpleParamter? @params)
|
||||
{
|
||||
if (Execute(@params) is T result)
|
||||
return result;
|
||||
return default;
|
||||
}
|
||||
|
||||
public object? Execute(PluginFunctionParameter? @params)
|
||||
public virtual object? Execute(PluginFunctionParameter? @params)
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
return ExecuteFunction(@params);
|
||||
#if !DEBUG
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
return ExecuteFunction(@params);
|
||||
}
|
||||
|
||||
protected abstract object? ExecuteFunction(PluginFunctionParameter? @params);
|
||||
|
||||
Reference in New Issue
Block a user