rename Pilz.Plugins.Advanced to Pilz.Features
This commit is contained in:
48
Pilz.Features/PluginFunction.cs
Normal file
48
Pilz.Features/PluginFunction.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
namespace Pilz.Features;
|
||||
|
||||
public abstract class PluginFunction : PluginFeature
|
||||
{
|
||||
protected PluginFunction(string type, string identifier) : base(type, identifier)
|
||||
{
|
||||
}
|
||||
|
||||
protected PluginFunction(string type, string identifier, string? name) : base(type, identifier, name)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual object? Execute()
|
||||
{
|
||||
return Execute((PluginFunctionParameter?)null);
|
||||
}
|
||||
|
||||
public virtual T? Execute<T>(params object?[]? @params)
|
||||
{
|
||||
return Execute<T>(new PluginFunctionSimpleParamter(@params));
|
||||
}
|
||||
|
||||
public virtual object? Execute(params object?[]? @params)
|
||||
{
|
||||
return Execute(new PluginFunctionSimpleParamter(@params));
|
||||
}
|
||||
|
||||
public virtual T? Execute<T>(PluginFunctionSimpleParamter? @params)
|
||||
{
|
||||
if (Execute(@params) is T result)
|
||||
return result;
|
||||
return default;
|
||||
}
|
||||
|
||||
public virtual object? Execute(PluginFunctionParameter? @params)
|
||||
{
|
||||
object? result = default;
|
||||
|
||||
if (OnPreExecute(@params, ref result))
|
||||
result = ExecuteFunction(@params);
|
||||
|
||||
OnPostExecute(@params, ref result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected abstract object? ExecuteFunction(PluginFunctionParameter? @params);
|
||||
}
|
||||
Reference in New Issue
Block a user