35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
namespace Pilz.Plugins.Advanced;
|
|
|
|
public static class Extensions
|
|
{
|
|
public static T? ExecuteIfEnabled<T>(this PluginFunction @this, params object?[]? @params)
|
|
{
|
|
return @this.Enabled ? @this.Execute<T>(@params) : default;
|
|
}
|
|
|
|
public static object? ExecuteIfEnabled(this PluginFunction @this, params object?[]? @params)
|
|
{
|
|
return @this.Enabled ? @this.Execute(@params) : default;
|
|
}
|
|
|
|
public static T? ExecuteIfEnabled<T>(this PluginFunction @this, PluginFunctionSimpleParamter? @params)
|
|
{
|
|
return @this.Enabled ? @this.Execute<T>(@params) : default;
|
|
}
|
|
|
|
public static object? ExecuteIfEnabled(this PluginFunction @this, PluginFunctionParameter? @params)
|
|
{
|
|
return @this.Enabled ? @this.Execute(@params) : default;
|
|
}
|
|
|
|
public static IEnumerable<T> Enabled<T>(this IEnumerable<T> @this) where T : PluginFeature
|
|
{
|
|
return @this.Where(n => n.Enabled);
|
|
}
|
|
|
|
public static IEnumerable<T> Ordered<T>(this IEnumerable<T> @this) where T : PluginFeature
|
|
{
|
|
return @this.OrderByDescending(n => n.Prioritization);
|
|
}
|
|
}
|