async PluginFunction
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>2.12.0</Version>
|
<Version>2.13.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -34,7 +34,7 @@ public abstract class PluginFunction : PluginFeature
|
|||||||
|
|
||||||
public virtual object? Execute(PluginFunctionParameter? @params)
|
public virtual object? Execute(PluginFunctionParameter? @params)
|
||||||
{
|
{
|
||||||
object? result = default;
|
object? result = null;
|
||||||
|
|
||||||
if (OnPreExecute(@params, ref result))
|
if (OnPreExecute(@params, ref result))
|
||||||
result = ExecuteFunction(@params);
|
result = ExecuteFunction(@params);
|
||||||
@@ -44,5 +44,47 @@ public abstract class PluginFunction : PluginFeature
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract object? ExecuteFunction(PluginFunctionParameter? @params);
|
public virtual Task<object?> ExecuteAsync()
|
||||||
|
{
|
||||||
|
return ExecuteAsync((PluginFunctionParameter?)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Task<T?> ExecuteAsync<T>(params object?[]? @params)
|
||||||
|
{
|
||||||
|
return ExecuteAsync<T>(new PluginFunctionSimpleParamter(@params));
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Task<object?> ExecuteAsync(params object?[]? @params)
|
||||||
|
{
|
||||||
|
return ExecuteAsync(new PluginFunctionSimpleParamter(@params));
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async Task<T?> ExecuteAsync<T>(PluginFunctionSimpleParamter? @params)
|
||||||
|
{
|
||||||
|
if (await ExecuteAsync(@params) is T result)
|
||||||
|
return result;
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async Task<object?> ExecuteAsync(PluginFunctionParameter? @params)
|
||||||
|
{
|
||||||
|
object? result = null;
|
||||||
|
|
||||||
|
if (OnPreExecute(@params, ref result))
|
||||||
|
result = await ExecuteFunctionAsync(@params);
|
||||||
|
|
||||||
|
OnPostExecute(@params, ref result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||||
|
{
|
||||||
|
return ExecuteFunctionAsync(@params).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual Task<object?> ExecuteFunctionAsync(PluginFunctionParameter? @params)
|
||||||
|
{
|
||||||
|
return Task.FromResult(ExecuteFunction(@params));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user