From 0043e9c0dc888c071885a88954fbabc772e96238 Mon Sep 17 00:00:00 2001 From: Laicasaane Date: Sat, 20 Feb 2021 19:34:54 +0700 Subject: [PATCH] Improve and add more value delegates functionality --- System.Delegates/Action/IAction.cs | 37 ++- System.Delegates/Action/IActionIn.cs | 35 ++- System.Delegates/Action/IActionRef.cs | 35 ++- System.Delegates/Func/IFunc.cs | 39 ++- System.Delegates/Func/IFuncIn.cs | 25 ++ System.Delegates/Func/IFuncRef.cs | 37 ++- System.Delegates/Predicate/IPredicate.cs | 37 ++- System.Delegates/Predicate/IPredicateIn.cs | 35 ++- System.Delegates/Predicate/IPredicateRef.cs | 35 ++- .../Action/ValueAction.Action.cs | 114 ++++++- .../Action/ValueAction.ActionIn.cs | 122 +++++++- .../Action/ValueAction.ActionRef.cs | 122 +++++++- System.ValueDelegates/Action/ValueAction.cs | 18 -- .../Delegate/ValueDelegate.Action.cs | 6 +- .../Delegate/ValueDelegate.ActionArgIn.cs | 277 ++++++++++++++++++ .../ValueDelegate.ActionArgIn.cs.meta | 11 + .../Delegate/ValueDelegate.FuncArgIn.cs | 277 ++++++++++++++++++ .../Delegate/ValueDelegate.FuncArgIn.cs.meta | 11 + .../Delegate/ValueDelegate.PredicateArgIn.cs | 277 ++++++++++++++++++ .../ValueDelegate.PredicateArgIn.cs.meta | 11 + System.ValueDelegates/Func/ValueFunc.Func.cs | 114 ++++++- .../Func/ValueFunc.FuncIn.cs | 122 +++++++- .../Func/ValueFunc.FuncRef.cs | 122 +++++++- System.ValueDelegates/Func/ValueFunc.cs | 12 - .../Predicate/ValuePredicate.Predicate.cs | 114 ++++++- .../Predicate/ValuePredicate.PredicateIn.cs | 122 +++++++- .../Predicate/ValuePredicate.PredicateRef.cs | 122 +++++++- .../Predicate/ValuePredicate.cs | 12 - 28 files changed, 2163 insertions(+), 138 deletions(-) create mode 100644 System.ValueDelegates/Delegate/ValueDelegate.ActionArgIn.cs create mode 100644 System.ValueDelegates/Delegate/ValueDelegate.ActionArgIn.cs.meta create mode 100644 System.ValueDelegates/Delegate/ValueDelegate.FuncArgIn.cs create mode 100644 System.ValueDelegates/Delegate/ValueDelegate.FuncArgIn.cs.meta create mode 100644 System.ValueDelegates/Delegate/ValueDelegate.PredicateArgIn.cs create mode 100644 System.ValueDelegates/Delegate/ValueDelegate.PredicateArgIn.cs.meta diff --git a/System.Delegates/Action/IAction.cs b/System.Delegates/Action/IAction.cs index 49fbbf5..e3a2712 100644 --- a/System.Delegates/Action/IAction.cs +++ b/System.Delegates/Action/IAction.cs @@ -5,33 +5,58 @@ public interface IAction void Invoke(); } - public interface IAction + public interface IAction { void Invoke(TClosure closure); } - public interface IAction : IAction + public interface IAction : IAction { void SetArguments(T arg); } - public interface IAction : IAction + public interface IAction : IAction { void SetArguments(T1 arg1, T2 arg2); } - public interface IAction : IAction + public interface IAction : IAction { void SetArguments(T1 arg1, T2 arg2, T3 arg3); } - public interface IAction : IAction + public interface IAction : IAction { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4); } - public interface IAction : IAction + public interface IAction : IAction { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); } + + public interface IActionArgIn : IAction + { + void SetArguments(in T arg); + } + + public interface IActionArgIn : IAction + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IActionArgIn : IAction + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IActionArgIn : IAction + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IActionArgIn : IAction + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.Delegates/Action/IActionIn.cs b/System.Delegates/Action/IActionIn.cs index 6aab396..623af9e 100644 --- a/System.Delegates/Action/IActionIn.cs +++ b/System.Delegates/Action/IActionIn.cs @@ -5,28 +5,53 @@ public interface IActionIn void Invoke(in TClosure closure); } - public interface IActionIn : IActionIn + public interface IActionIn : IActionIn { void SetArguments(T arg); } - public interface IActionIn : IActionIn + public interface IActionIn : IActionIn { void SetArguments(T1 arg1, T2 arg2); } - public interface IActionIn : IActionIn + public interface IActionIn : IActionIn { void SetArguments(T1 arg1, T2 arg2, T3 arg3); } - public interface IActionIn : IActionIn + public interface IActionIn : IActionIn { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4); } - public interface IActionIn : IActionIn + public interface IActionIn : IActionIn { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); } + + public interface IActionInArgIn : IActionIn + { + void SetArguments(in T arg); + } + + public interface IActionInArgIn : IActionIn + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IActionInArgIn : IActionIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IActionInArgIn : IActionIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IActionInArgIn : IActionIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.Delegates/Action/IActionRef.cs b/System.Delegates/Action/IActionRef.cs index ef612db..0b36440 100644 --- a/System.Delegates/Action/IActionRef.cs +++ b/System.Delegates/Action/IActionRef.cs @@ -5,28 +5,53 @@ public interface IActionRef void Invoke(ref TClosure closure); } - public interface IActionRef : IActionRef + public interface IActionRef : IActionRef { void SetArguments(T arg); } - public interface IActionRef : IActionRef + public interface IActionRef : IActionRef { void SetArguments(T1 arg1, T2 arg2); } - public interface IActionRef : IActionRef + public interface IActionRef : IActionRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3); } - public interface IActionRef : IActionRef + public interface IActionRef : IActionRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4); } - public interface IActionRef : IActionRef + public interface IActionRef : IActionRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); } + + public interface IActionRefArgIn : IActionRef + { + void SetArguments(in T arg); + } + + public interface IActionRefArgIn : IActionRef + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IActionRefArgIn : IActionRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IActionRefArgIn : IActionRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IActionRefArgIn : IActionRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.Delegates/Func/IFunc.cs b/System.Delegates/Func/IFunc.cs index fb728e8..2af43d7 100644 --- a/System.Delegates/Func/IFunc.cs +++ b/System.Delegates/Func/IFunc.cs @@ -1,37 +1,62 @@ namespace System.Delegates { - public interface IFunc + public interface IFunc { TResult Invoke(); } - public interface IFunc + public interface IFunc { TResult Invoke(TClosure closure); } - public interface IFunc : IFunc + public interface IFunc : IFunc { void SetArguments(T arg); } - public interface IFunc : IFunc + public interface IFunc : IFunc { void SetArguments(T1 arg1, T2 arg2); } - public interface IFunc : IFunc + public interface IFunc : IFunc { void SetArguments(T1 arg1, T2 arg2, T3 arg3); } - public interface IFunc : IFunc + public interface IFunc : IFunc { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4); } - public interface IFunc : IFunc + public interface IFunc : IFunc { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); } + + public interface IFuncArgIn : IFunc + { + void SetArguments(in T arg); + } + + public interface IFuncArgIn : IFunc + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IFuncArgIn : IFunc + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IFuncArgIn : IFunc + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IFuncArgIn : IFunc + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.Delegates/Func/IFuncIn.cs b/System.Delegates/Func/IFuncIn.cs index 701e2c9..f569f69 100644 --- a/System.Delegates/Func/IFuncIn.cs +++ b/System.Delegates/Func/IFuncIn.cs @@ -29,4 +29,29 @@ public interface IFuncIn : IFuncIn : IFuncIn + { + void SetArguments(in T arg); + } + + public interface IFuncInArgIn : IFuncIn + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IFuncInArgIn : IFuncIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IFuncInArgIn : IFuncIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IFuncInArgIn : IFuncIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.Delegates/Func/IFuncRef.cs b/System.Delegates/Func/IFuncRef.cs index f7bb485..1d7db38 100644 --- a/System.Delegates/Func/IFuncRef.cs +++ b/System.Delegates/Func/IFuncRef.cs @@ -1,32 +1,57 @@ namespace System.Delegates { - public interface IFuncRef + public interface IFuncRef { TResult Invoke(ref TClosure closure); } - public interface IFuncRef : IFuncRef + public interface IFuncRef : IFuncRef { void SetArguments(T arg); } - public interface IFuncRef : IFuncRef + public interface IFuncRef : IFuncRef { void SetArguments(T1 arg1, T2 arg2); } - public interface IFuncRef : IFuncRef + public interface IFuncRef : IFuncRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3); } - public interface IFuncRef : IFuncRef + public interface IFuncRef : IFuncRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4); } - public interface IFuncRef : IFuncRef + public interface IFuncRef : IFuncRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); } + + public interface IFuncRefArgIn : IFuncRef + { + void SetArguments(in T arg); + } + + public interface IFuncRefArgIn : IFuncRef + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IFuncRefArgIn : IFuncRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IFuncRefArgIn : IFuncRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IFuncRefArgIn : IFuncRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.Delegates/Predicate/IPredicate.cs b/System.Delegates/Predicate/IPredicate.cs index c8c7558..6aeaff7 100644 --- a/System.Delegates/Predicate/IPredicate.cs +++ b/System.Delegates/Predicate/IPredicate.cs @@ -5,33 +5,58 @@ public interface IPredicate bool Invoke(); } - public interface IPredicate + public interface IPredicate { bool Invoke(TClosure closure); } - public interface IPredicate : IPredicate + public interface IPredicate : IPredicate { void SetArguments(T arg); } - public interface IPredicate : IPredicate + public interface IPredicate : IPredicate { void SetArguments(T1 arg1, T2 arg2); } - public interface IPredicate : IPredicate + public interface IPredicate : IPredicate { void SetArguments(T1 arg1, T2 arg2, T3 arg3); } - public interface IPredicate : IPredicate + public interface IPredicate : IPredicate { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4); } - public interface IPredicate : IPredicate + public interface IPredicate : IPredicate { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); } + + public interface IPredicateArgIn : IPredicate + { + void SetArguments(in T arg); + } + + public interface IPredicateArgIn : IPredicate + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IPredicateArgIn : IPredicate + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IPredicateArgIn : IPredicate + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IPredicateArgIn : IPredicate + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.Delegates/Predicate/IPredicateIn.cs b/System.Delegates/Predicate/IPredicateIn.cs index 8062891..d7baed6 100644 --- a/System.Delegates/Predicate/IPredicateIn.cs +++ b/System.Delegates/Predicate/IPredicateIn.cs @@ -5,28 +5,53 @@ public interface IPredicateIn bool Invoke(in TClosure closure); } - public interface IPredicateIn : IPredicateIn + public interface IPredicateIn : IPredicateIn { void SetArguments(T arg); } - public interface IPredicateIn : IPredicateIn + public interface IPredicateIn : IPredicateIn { void SetArguments(T1 arg1, T2 arg2); } - public interface IPredicateIn : IPredicateIn + public interface IPredicateIn : IPredicateIn { void SetArguments(T1 arg1, T2 arg2, T3 arg3); } - public interface IPredicateIn : IPredicateIn + public interface IPredicateIn : IPredicateIn { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4); } - public interface IPredicateIn : IPredicateIn + public interface IPredicateIn : IPredicateIn { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); } + + public interface IPredicateInArgIn : IPredicateIn + { + void SetArguments(in T arg); + } + + public interface IPredicateInArgIn : IPredicateIn + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IPredicateInArgIn : IPredicateIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IPredicateInArgIn : IPredicateIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IPredicateInArgIn : IPredicateIn + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.Delegates/Predicate/IPredicateRef.cs b/System.Delegates/Predicate/IPredicateRef.cs index d40bd54..95c0caf 100644 --- a/System.Delegates/Predicate/IPredicateRef.cs +++ b/System.Delegates/Predicate/IPredicateRef.cs @@ -5,28 +5,53 @@ public interface IPredicateRef bool Invoke(ref TClosure closure); } - public interface IPredicateRef : IPredicateRef + public interface IPredicateRef : IPredicateRef { void SetArguments(T arg); } - public interface IPredicateRef : IPredicateRef + public interface IPredicateRef : IPredicateRef { void SetArguments(T1 arg1, T2 arg2); } - public interface IPredicateRef : IPredicateRef + public interface IPredicateRef : IPredicateRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3); } - public interface IPredicateRef : IPredicateRef + public interface IPredicateRef : IPredicateRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4); } - public interface IPredicateRef : IPredicateRef + public interface IPredicateRef : IPredicateRef { void SetArguments(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); } + + public interface IPredicateRefArgIn : IPredicateRef + { + void SetArguments(in T arg); + } + + public interface IPredicateRefArgIn : IPredicateRef + { + void SetArguments(in T1 arg1, in T2 arg2); + } + + public interface IPredicateRefArgIn : IPredicateRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3); + } + + public interface IPredicateRefArgIn : IPredicateRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4); + } + + public interface IPredicateRefArgIn : IPredicateRef + { + void SetArguments(in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5); + } } \ No newline at end of file diff --git a/System.ValueDelegates/Action/ValueAction.Action.cs b/System.ValueDelegates/Action/ValueAction.Action.cs index 0952e2c..bf6f737 100644 --- a/System.ValueDelegates/Action/ValueAction.Action.cs +++ b/System.ValueDelegates/Action/ValueAction.Action.cs @@ -4,10 +4,6 @@ namespace System.ValueDelegates { public static partial class ValueAction { - public static void Invoke() - where TAction : struct, IAction - => new TAction().Invoke(); - public static void Invoke(this TAction action, TClosure closure, T arg) where TAction : struct, IAction { @@ -121,5 +117,115 @@ public static void Invoke(this TClosure c action.SetArguments(arg1, arg2, arg3, arg4, arg5); action.Invoke(closure); } + + public static void Invoke(this TAction action, TClosure closure, in T arg) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg); + action.Invoke(closure); + } + + public static void Invoke(this TAction action, TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg1, in arg2); + action.Invoke(closure); + } + + public static void Invoke(this TAction action, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(closure); + } + + public static void Invoke(this TAction action, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + action.Invoke(closure); + } + + public static void Invoke(this TAction action, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(closure); + } + + public static void Invoke(in TAction action, TClosure closure, in T arg) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg); + action.Invoke(closure); + } + + public static void Invoke(in TAction action, TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg1, in arg2); + action.Invoke(closure); + } + + public static void Invoke(in TAction action, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(closure); + } + + public static void Invoke(in TAction action, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionArgIn + { + action.SetArguments(arg1, arg2, arg3, arg4); + action.Invoke(closure); + } + + public static void Invoke(in TAction action, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(closure); + } + + public static void Invoke(this TClosure closure, in T arg) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + action.Invoke(closure); + } + + public static void Invoke(this TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + action.Invoke(closure); + } + + public static void Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(closure); + } + + public static void Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + action.Invoke(closure); + } + + public static void Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Action/ValueAction.ActionIn.cs b/System.ValueDelegates/Action/ValueAction.ActionIn.cs index 0e390f6..f387a1e 100644 --- a/System.ValueDelegates/Action/ValueAction.ActionIn.cs +++ b/System.ValueDelegates/Action/ValueAction.ActionIn.cs @@ -4,11 +4,11 @@ namespace System.ValueDelegates { public static partial class ValueAction { - public static void Invoke(in TClosure closure) + public static void InvokeIn(this TClosure closure) where TAction : struct, IActionIn => new TAction().Invoke(in closure); - public static void Invoke(in TClosure closure, T arg) + public static void InvokeIn(this TClosure closure, T arg) where TAction : struct, IActionIn { var action = new TAction(); @@ -16,7 +16,7 @@ public static void Invoke(in TClosure closure, T arg) action.Invoke(in closure); } - public static void Invoke(in TClosure closure, T1 arg1, T2 arg2) + public static void InvokeIn(this TClosure closure, T1 arg1, T2 arg2) where TAction : struct, IActionIn { var action = new TAction(); @@ -24,7 +24,7 @@ public static void Invoke(in TClosure closure, T1 arg action.Invoke(in closure); } - public static void Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3) + public static void InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3) where TAction : struct, IActionIn { var action = new TAction(); @@ -32,7 +32,7 @@ public static void Invoke(in TClosure closure, T1 action.Invoke(in closure); } - public static void Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + public static void InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) where TAction : struct, IActionIn { var action = new TAction(); @@ -40,7 +40,7 @@ public static void Invoke(in TClosure closure action.Invoke(in closure); } - public static void Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + public static void InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) where TAction : struct, IActionIn { var action = new TAction(); @@ -117,5 +117,115 @@ public static void Invoke(in TAction acti action.SetArguments(arg1, arg2, arg3, arg4, arg5); action.Invoke(in closure); } + + public static void Invoke(this TAction action, in TClosure closure, in T arg) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg); + action.Invoke(in closure); + } + + public static void Invoke(this TAction action, in TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg1, in arg2); + action.Invoke(in closure); + } + + public static void Invoke(this TAction action, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(in closure); + } + + public static void Invoke(this TAction action, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + action.Invoke(in closure); + } + + public static void Invoke(this TAction action, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(in closure); + } + + public static void Invoke(in TAction action, in TClosure closure, in T arg) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg); + action.Invoke(in closure); + } + + public static void Invoke(in TAction action, in TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg1, in arg2); + action.Invoke(in closure); + } + + public static void Invoke(in TAction action, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(in closure); + } + + public static void Invoke(in TAction action, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionInArgIn + { + action.SetArguments(arg1, arg2, arg3, arg4); + action.Invoke(in closure); + } + + public static void Invoke(in TAction action, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionInArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(in closure); + } + + public static void InvokeIn(this TClosure closure, in T arg) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + action.Invoke(in closure); + } + + public static void InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + action.Invoke(in closure); + } + + public static void InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(in closure); + } + + public static void InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + action.Invoke(in closure); + } + + public static void InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(in closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Action/ValueAction.ActionRef.cs b/System.ValueDelegates/Action/ValueAction.ActionRef.cs index 3a0a3e4..3a87d85 100644 --- a/System.ValueDelegates/Action/ValueAction.ActionRef.cs +++ b/System.ValueDelegates/Action/ValueAction.ActionRef.cs @@ -4,11 +4,11 @@ namespace System.ValueDelegates { public static partial class ValueAction { - public static void InvokeRef(ref TClosure closure) + public static void InvokeRef(this TClosure closure) where TAction : struct, IActionRef => new TAction().Invoke(ref closure); - public static void InvokeRef(ref TClosure closure, T arg) + public static void InvokeRef(this TClosure closure, T arg) where TAction : struct, IActionRef { var action = new TAction(); @@ -16,7 +16,7 @@ public static void InvokeRef(ref TClosure closure, T arg) action.Invoke(ref closure); } - public static void InvokeRef(ref TClosure closure, T1 arg1, T2 arg2) + public static void InvokeRef(this TClosure closure, T1 arg1, T2 arg2) where TAction : struct, IActionRef { var action = new TAction(); @@ -24,7 +24,7 @@ public static void InvokeRef(ref TClosure closure, T1 action.Invoke(ref closure); } - public static void InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3) + public static void InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3) where TAction : struct, IActionRef { var action = new TAction(); @@ -32,7 +32,7 @@ public static void InvokeRef(ref TClosure closure action.Invoke(ref closure); } - public static void InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + public static void InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) where TAction : struct, IActionRef { var action = new TAction(); @@ -40,7 +40,7 @@ public static void InvokeRef(ref TClosure clo action.Invoke(ref closure); } - public static void InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + public static void InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) where TAction : struct, IActionRef { var action = new TAction(); @@ -117,5 +117,115 @@ public static void InvokeRef(in TAction a action.SetArguments(arg1, arg2, arg3, arg4, arg5); action.Invoke(ref closure); } + + public static void InvokeRef(this TAction action, ref TClosure closure, in T arg) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TAction action, ref TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg1, in arg2); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TAction action, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TAction action, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TAction action, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(ref closure); + } + + public static void InvokeRef(in TAction action, ref TClosure closure, in T arg) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg); + action.Invoke(ref closure); + } + + public static void InvokeRef(in TAction action, ref TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg1, in arg2); + action.Invoke(ref closure); + } + + public static void InvokeRef(in TAction action, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(ref closure); + } + + public static void InvokeRef(in TAction action, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(arg1, arg2, arg3, arg4); + action.Invoke(ref closure); + } + + public static void InvokeRef(in TAction action, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionRefArgIn + { + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TClosure closure, in T arg) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + action.Invoke(ref closure); + } + + public static void InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + action.Invoke(ref closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Action/ValueAction.cs b/System.ValueDelegates/Action/ValueAction.cs index 0f2de2d..5822802 100644 --- a/System.ValueDelegates/Action/ValueAction.cs +++ b/System.ValueDelegates/Action/ValueAction.cs @@ -14,12 +14,6 @@ public ValueAction(TClosure closure) this.closure = closure; } - public ValueAction(in TClosure closure) - { - this.action = new TAction(); - this.closure = closure; - } - public ValueAction(TAction action, TClosure closure) { this.action = action; @@ -32,18 +26,6 @@ public ValueAction(in TAction action, TClosure closure) this.closure = closure; } - public ValueAction(TAction action, in TClosure closure) - { - this.action = action; - this.closure = closure; - } - - public ValueAction(in TAction action, in TClosure closure) - { - this.action = action; - this.closure = closure; - } - public void Invoke() => this.action.Invoke(this.closure); } diff --git a/System.ValueDelegates/Delegate/ValueDelegate.Action.cs b/System.ValueDelegates/Delegate/ValueDelegate.Action.cs index 0665f9f..136db79 100644 --- a/System.ValueDelegates/Delegate/ValueDelegate.Action.cs +++ b/System.ValueDelegates/Delegate/ValueDelegate.Action.cs @@ -50,12 +50,12 @@ public static ValueAction ValueAction(in action, in closure); + return new ValueAction(in action, closure); } public static ValueActionIn ValueActionIn(this object closure) where TAction : struct, IActionIn - => new ValueActionIn(new TAction(), closure); + => new ValueActionIn(new TAction(), in closure); public static ValueActionIn ValueActionIn(this object closure, T arg) where TAction : struct, IActionIn @@ -197,7 +197,7 @@ public static ValueAction ValueAction(in action, in closure); + return new ValueAction(in action, closure); } public static ValueActionIn ValueActionIn(this TClosure closure) diff --git a/System.ValueDelegates/Delegate/ValueDelegate.ActionArgIn.cs b/System.ValueDelegates/Delegate/ValueDelegate.ActionArgIn.cs new file mode 100644 index 0000000..6126514 --- /dev/null +++ b/System.ValueDelegates/Delegate/ValueDelegate.ActionArgIn.cs @@ -0,0 +1,277 @@ +using System.Delegates; + +namespace System.ValueDelegates +{ + public static partial class ValueDelegate + { + public static ValueAction ValueAction(this object closure, in T arg) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + + return new ValueAction(in action, closure); + } + + public static ValueAction ValueAction(this object closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + + return new ValueAction(in action, closure); + } + + public static ValueAction ValueAction(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + + return new ValueAction(in action, closure); + } + + public static ValueAction ValueAction(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueAction(in action, closure); + } + + public static ValueAction ValueAction(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueAction(in action, closure); + } + + public static ValueActionIn ValueActionIn(this object closure, in T arg) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionIn ValueActionIn(this object closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionIn ValueActionIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionIn ValueActionIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionIn ValueActionIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionRef ValueActionRef(this object closure, in T arg) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueActionRef ValueActionRef(this object closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueActionRef ValueActionRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueActionRef ValueActionRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueActionRef ValueActionRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueAction ValueAction(this TClosure closure, in T arg) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + + return new ValueAction(in action, closure); + } + + public static ValueAction ValueAction(this TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + + return new ValueAction(in action, closure); + } + + public static ValueAction ValueAction(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + + return new ValueAction(in action, closure); + } + + public static ValueAction ValueAction(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueAction(in action, closure); + } + + public static ValueAction ValueAction(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueAction(in action, closure); + } + + public static ValueActionIn ValueActionIn(this TClosure closure, in T arg) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionIn ValueActionIn(this TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionIn ValueActionIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionIn ValueActionIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionIn ValueActionIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionInArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueActionIn(in action, in closure); + } + + public static ValueActionRef ValueActionRef(this TClosure closure, in T arg) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueActionRef ValueActionRef(this TClosure closure, in T1 arg1, in T2 arg2) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueActionRef ValueActionRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueActionRef ValueActionRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueActionRef(in action, ref closure); + } + + public static ValueActionRef ValueActionRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TAction : struct, IActionRefArgIn + { + var action = new TAction(); + action.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueActionRef(in action, ref closure); + } + } +} \ No newline at end of file diff --git a/System.ValueDelegates/Delegate/ValueDelegate.ActionArgIn.cs.meta b/System.ValueDelegates/Delegate/ValueDelegate.ActionArgIn.cs.meta new file mode 100644 index 0000000..23a01e7 --- /dev/null +++ b/System.ValueDelegates/Delegate/ValueDelegate.ActionArgIn.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 86a81c6471183ff46a5e89bc8f6f3070 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/System.ValueDelegates/Delegate/ValueDelegate.FuncArgIn.cs b/System.ValueDelegates/Delegate/ValueDelegate.FuncArgIn.cs new file mode 100644 index 0000000..77a8e86 --- /dev/null +++ b/System.ValueDelegates/Delegate/ValueDelegate.FuncArgIn.cs @@ -0,0 +1,277 @@ +using System.Delegates; + +namespace System.ValueDelegates +{ + public static partial class ValueDelegate + { + public static ValueFunc ValueFunc(this object closure, in T arg) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + + return new ValueFunc(in func, closure); + } + + public static ValueFunc ValueFunc(this object closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + + return new ValueFunc(in func, closure); + } + + public static ValueFunc ValueFunc(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + + return new ValueFunc(in func, closure); + } + + public static ValueFunc ValueFunc(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueFunc(in func, closure); + } + + public static ValueFunc ValueFunc(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueFunc(in func, closure); + } + + public static ValueFuncIn ValueFuncIn(this object closure, in T arg) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncIn ValueFuncIn(this object closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncIn ValueFuncIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncIn ValueFuncIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncIn ValueFuncIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncRef ValueFuncRef(this object closure, in T arg) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFuncRef ValueFuncRef(this object closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFuncRef ValueFuncRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFuncRef ValueFuncRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFuncRef ValueFuncRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFunc ValueFunc(this TClosure closure, in T arg) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + + return new ValueFunc(in func, closure); + } + + public static ValueFunc ValueFunc(this TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + + return new ValueFunc(in func, closure); + } + + public static ValueFunc ValueFunc(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + + return new ValueFunc(in func, closure); + } + + public static ValueFunc ValueFunc(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueFunc(in func, closure); + } + + public static ValueFunc ValueFunc(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueFunc(in func, closure); + } + + public static ValueFuncIn ValueFuncIn(this TClosure closure, in T arg) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncIn ValueFuncIn(this TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncIn ValueFuncIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncIn ValueFuncIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncIn ValueFuncIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueFuncIn(in func, in closure); + } + + public static ValueFuncRef ValueFuncRef(this TClosure closure, in T arg) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFuncRef ValueFuncRef(this TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFuncRef ValueFuncRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFuncRef ValueFuncRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValueFuncRef(in func, ref closure); + } + + public static ValueFuncRef ValueFuncRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValueFuncRef(in func, ref closure); + } + } +} \ No newline at end of file diff --git a/System.ValueDelegates/Delegate/ValueDelegate.FuncArgIn.cs.meta b/System.ValueDelegates/Delegate/ValueDelegate.FuncArgIn.cs.meta new file mode 100644 index 0000000..74cdbd0 --- /dev/null +++ b/System.ValueDelegates/Delegate/ValueDelegate.FuncArgIn.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ee0eea985fca8949bb77615e546e41e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/System.ValueDelegates/Delegate/ValueDelegate.PredicateArgIn.cs b/System.ValueDelegates/Delegate/ValueDelegate.PredicateArgIn.cs new file mode 100644 index 0000000..f6c74bc --- /dev/null +++ b/System.ValueDelegates/Delegate/ValueDelegate.PredicateArgIn.cs @@ -0,0 +1,277 @@ +using System.Delegates; + +namespace System.ValueDelegates +{ + public static partial class ValueDelegate + { + public static ValuePredicate ValuePredicate(this object closure, in T arg) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicate ValuePredicate(this object closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicate ValuePredicate(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicate ValuePredicate(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicate ValuePredicate(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicateIn ValuePredicateIn(this object closure, in T arg) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateIn ValuePredicateIn(this object closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateIn ValuePredicateIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateIn ValuePredicateIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateIn ValuePredicateIn(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateRef ValuePredicateRef(this object closure, in T arg) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicateRef ValuePredicateRef(this object closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicateRef ValuePredicateRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicateRef ValuePredicateRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicateRef ValuePredicateRef(this object closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicate ValuePredicate(this TClosure closure, in T arg) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicate ValuePredicate(this TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicate ValuePredicate(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicate ValuePredicate(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicate ValuePredicate(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValuePredicate(in predicate, closure); + } + + public static ValuePredicateIn ValuePredicateIn(this TClosure closure, in T arg) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateIn ValuePredicateIn(this TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateIn ValuePredicateIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateIn ValuePredicateIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateIn ValuePredicateIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValuePredicateIn(in predicate, in closure); + } + + public static ValuePredicateRef ValuePredicateRef(this TClosure closure, in T arg) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicateRef ValuePredicateRef(this TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicateRef ValuePredicateRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicateRef ValuePredicateRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + + return new ValuePredicateRef(in predicate, ref closure); + } + + public static ValuePredicateRef ValuePredicateRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + + return new ValuePredicateRef(in predicate, ref closure); + } + } +} \ No newline at end of file diff --git a/System.ValueDelegates/Delegate/ValueDelegate.PredicateArgIn.cs.meta b/System.ValueDelegates/Delegate/ValueDelegate.PredicateArgIn.cs.meta new file mode 100644 index 0000000..d85f219 --- /dev/null +++ b/System.ValueDelegates/Delegate/ValueDelegate.PredicateArgIn.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 94e7e034c4259154083fe9b000a6b281 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/System.ValueDelegates/Func/ValueFunc.Func.cs b/System.ValueDelegates/Func/ValueFunc.Func.cs index 15b6470..997cc65 100644 --- a/System.ValueDelegates/Func/ValueFunc.Func.cs +++ b/System.ValueDelegates/Func/ValueFunc.Func.cs @@ -4,10 +4,6 @@ namespace System.ValueDelegates { public static partial class ValueFunc { - public static TResult Invoke() - where TFunc : struct, IFunc - => new TFunc().Invoke(); - public static TResult Invoke(this TFunc func, TClosure closure, T arg) where TFunc : struct, IFunc { @@ -121,5 +117,115 @@ public static TResult Invoke(this func.SetArguments(arg1, arg2, arg3, arg4, arg5); return func.Invoke(closure); } + + public static TResult Invoke(this TFunc func, TClosure closure, in T arg) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg); + return func.Invoke(closure); + } + + public static TResult Invoke(this TFunc func, TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg1, in arg2); + return func.Invoke(closure); + } + + public static TResult Invoke(this TFunc func, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(closure); + } + + public static TResult Invoke(this TFunc func, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(closure); + } + + public static TResult Invoke(this TFunc func, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(closure); + } + + public static TResult Invoke(in TFunc func, TClosure closure, in T arg) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg); + return func.Invoke(closure); + } + + public static TResult Invoke(in TFunc func, TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg1, in arg2); + return func.Invoke(closure); + } + + public static TResult Invoke(in TFunc func, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(closure); + } + + public static TResult Invoke(in TFunc func, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(closure); + } + + public static TResult Invoke(in TFunc func, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(closure); + } + + public static TResult Invoke(this TClosure closure, in T arg) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + return func.Invoke(closure); + } + + public static TResult Invoke(this TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + return func.Invoke(closure); + } + + public static TResult Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(closure); + } + + public static TResult Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(closure); + } + + public static TResult Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Func/ValueFunc.FuncIn.cs b/System.ValueDelegates/Func/ValueFunc.FuncIn.cs index 2e4bb9f..ca713d7 100644 --- a/System.ValueDelegates/Func/ValueFunc.FuncIn.cs +++ b/System.ValueDelegates/Func/ValueFunc.FuncIn.cs @@ -4,11 +4,11 @@ namespace System.ValueDelegates { public static partial class ValueFunc { - public static TResult Invoke(in TClosure closure) + public static TResult InvokeIn(this TClosure closure) where TFunc : struct, IFuncIn => new TFunc().Invoke(in closure); - public static TResult Invoke(in TClosure closure, T arg) + public static TResult InvokeIn(this TClosure closure, T arg) where TFunc : struct, IFuncIn { var func = new TFunc(); @@ -16,7 +16,7 @@ public static TResult Invoke(in TClosure closure, T return func.Invoke(in closure); } - public static TResult Invoke(in TClosure closure, T1 arg1, T2 arg2) + public static TResult InvokeIn(this TClosure closure, T1 arg1, T2 arg2) where TFunc : struct, IFuncIn { var func = new TFunc(); @@ -24,7 +24,7 @@ public static TResult Invoke(in TClosure closu return func.Invoke(in closure); } - public static TResult Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3) + public static TResult InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3) where TFunc : struct, IFuncIn { var func = new TFunc(); @@ -32,7 +32,7 @@ public static TResult Invoke(in TClosure c return func.Invoke(in closure); } - public static TResult Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + public static TResult InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) where TFunc : struct, IFuncIn { var func = new TFunc(); @@ -40,7 +40,7 @@ public static TResult Invoke(in TClosu return func.Invoke(in closure); } - public static TResult Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + public static TResult InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) where TFunc : struct, IFuncIn { var func = new TFunc(); @@ -117,5 +117,115 @@ public static TResult Invoke(in TF func.SetArguments(arg1, arg2, arg3, arg4, arg5); return func.Invoke(in closure); } + + public static TResult InvokeIn(this TClosure closure, in T arg) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + return func.Invoke(in closure); + } + + public static TResult InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + return func.Invoke(in closure); + } + + public static TResult InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(in closure); + } + + public static TResult InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(in closure); + } + + public static TResult InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncInArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(in closure); + } + + public static TResult Invoke(this TFunc func, in TClosure closure, in T arg) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg); + return func.Invoke(in closure); + } + + public static TResult Invoke(this TFunc func, in TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg1, in arg2); + return func.Invoke(in closure); + } + + public static TResult Invoke(this TFunc func, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(in closure); + } + + public static TResult Invoke(this TFunc func, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(in closure); + } + + public static TResult Invoke(this TFunc func, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(in closure); + } + + public static TResult Invoke(in TFunc func, in TClosure closure, in T arg) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg); + return func.Invoke(in closure); + } + + public static TResult Invoke(in TFunc func, in TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg1, in arg2); + return func.Invoke(in closure); + } + + public static TResult Invoke(in TFunc func, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(in closure); + } + + public static TResult Invoke(in TFunc func, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(in closure); + } + + public static TResult Invoke(in TFunc func, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncInArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(in closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Func/ValueFunc.FuncRef.cs b/System.ValueDelegates/Func/ValueFunc.FuncRef.cs index 7daeb97..82eb850 100644 --- a/System.ValueDelegates/Func/ValueFunc.FuncRef.cs +++ b/System.ValueDelegates/Func/ValueFunc.FuncRef.cs @@ -4,11 +4,11 @@ namespace System.ValueDelegates { public static partial class ValueFunc { - public static TResult InvokeRef(ref TClosure closure) + public static TResult InvokeRef(this TClosure closure) where TFunc : struct, IFuncRef => new TFunc().Invoke(ref closure); - public static TResult InvokeRef(ref TClosure closure, T arg) + public static TResult InvokeRef(this TClosure closure, T arg) where TFunc : struct, IFuncRef { var func = new TFunc(); @@ -16,7 +16,7 @@ public static TResult InvokeRef(ref TClosure closur return func.Invoke(ref closure); } - public static TResult InvokeRef(ref TClosure closure, T1 arg1, T2 arg2) + public static TResult InvokeRef(this TClosure closure, T1 arg1, T2 arg2) where TFunc : struct, IFuncRef { var func = new TFunc(); @@ -24,7 +24,7 @@ public static TResult InvokeRef(ref TClosure c return func.Invoke(ref closure); } - public static TResult InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3) + public static TResult InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3) where TFunc : struct, IFuncRef { var func = new TFunc(); @@ -32,7 +32,7 @@ public static TResult InvokeRef(ref TClosu return func.Invoke(ref closure); } - public static TResult InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + public static TResult InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) where TFunc : struct, IFuncRef { var func = new TFunc(); @@ -40,7 +40,7 @@ public static TResult InvokeRef(ref TC return func.Invoke(ref closure); } - public static TResult InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + public static TResult InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) where TFunc : struct, IFuncRef { var func = new TFunc(); @@ -117,5 +117,115 @@ public static TResult InvokeRef(in func.SetArguments(arg1, arg2, arg3, arg4, arg5); return func.Invoke(ref closure); } + + public static TResult InvokeRef(this TClosure closure, in T arg) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncRefArgIn + { + var func = new TFunc(); + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TFunc func, ref TClosure closure, in T arg) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TFunc func, ref TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg1, in arg2); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TFunc func, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TFunc func, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(this TFunc func, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(in TFunc func, ref TClosure closure, in T arg) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(in TFunc func, ref TClosure closure, in T1 arg1, in T2 arg2) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg1, in arg2); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(in TFunc func, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg1, in arg2, in arg3); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(in TFunc func, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4); + return func.Invoke(ref closure); + } + + public static TResult InvokeRef(in TFunc func, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TFunc : struct, IFuncRefArgIn + { + func.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return func.Invoke(ref closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Func/ValueFunc.cs b/System.ValueDelegates/Func/ValueFunc.cs index 37de13b..1b8708a 100644 --- a/System.ValueDelegates/Func/ValueFunc.cs +++ b/System.ValueDelegates/Func/ValueFunc.cs @@ -14,12 +14,6 @@ public ValueFunc(TClosure closure) this.closure = closure; } - public ValueFunc(in TClosure closure) - { - this.func = new TFunc(); - this.closure = closure; - } - public ValueFunc(TFunc action, TClosure closure) { this.func = action; @@ -38,12 +32,6 @@ public ValueFunc(TFunc action, in TClosure closure) this.closure = closure; } - public ValueFunc(in TFunc action, in TClosure closure) - { - this.func = action; - this.closure = closure; - } - public TResult Invoke() => this.func.Invoke(this.closure); } diff --git a/System.ValueDelegates/Predicate/ValuePredicate.Predicate.cs b/System.ValueDelegates/Predicate/ValuePredicate.Predicate.cs index 1285d99..9420c57 100644 --- a/System.ValueDelegates/Predicate/ValuePredicate.Predicate.cs +++ b/System.ValueDelegates/Predicate/ValuePredicate.Predicate.cs @@ -4,10 +4,6 @@ namespace System.ValueDelegates { public static partial class ValuePredicate { - public static bool Invoke() - where TPredicate : struct, IPredicate - => new TPredicate().Invoke(); - public static bool Invoke(this TPredicate predicate, TClosure closure, T arg) where TPredicate : struct, IPredicate { @@ -121,5 +117,115 @@ public static bool Invoke(this TClosur predicate.SetArguments(arg1, arg2, arg3, arg4, arg5); return predicate.Invoke(closure); } + + public static bool Invoke(this TPredicate predicate, TClosure closure, in T arg) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TPredicate predicate, TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TPredicate predicate, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TPredicate predicate, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TPredicate predicate, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(closure); + } + + public static bool Invoke(in TPredicate predicate, TClosure closure, in T arg) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg); + return predicate.Invoke(closure); + } + + public static bool Invoke(in TPredicate predicate, TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(closure); + } + + public static bool Invoke(in TPredicate predicate, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(closure); + } + + public static bool Invoke(in TPredicate predicate, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(closure); + } + + public static bool Invoke(in TPredicate predicate, TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TClosure closure, in T arg) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(closure); + } + + public static bool Invoke(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Predicate/ValuePredicate.PredicateIn.cs b/System.ValueDelegates/Predicate/ValuePredicate.PredicateIn.cs index b2b11f5..dbc84dd 100644 --- a/System.ValueDelegates/Predicate/ValuePredicate.PredicateIn.cs +++ b/System.ValueDelegates/Predicate/ValuePredicate.PredicateIn.cs @@ -4,11 +4,11 @@ namespace System.ValueDelegates { public static partial class ValuePredicate { - public static bool Invoke(in TClosure closure) + public static bool InvokeIn(this TClosure closure) where TPredicate : struct, IPredicateIn => new TPredicate().Invoke(in closure); - public static bool Invoke(in TClosure closure, T arg) + public static bool InvokeIn(this TClosure closure, T arg) where TPredicate : struct, IPredicateIn { var predicate = new TPredicate(); @@ -16,7 +16,7 @@ public static bool Invoke(in TClosure closure, T arg) return predicate.Invoke(in closure); } - public static bool Invoke(in TClosure closure, T1 arg1, T2 arg2) + public static bool InvokeIn(this TClosure closure, T1 arg1, T2 arg2) where TPredicate : struct, IPredicateIn { var predicate = new TPredicate(); @@ -24,7 +24,7 @@ public static bool Invoke(in TClosure closure, T1 return predicate.Invoke(in closure); } - public static bool Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3) + public static bool InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3) where TPredicate : struct, IPredicateIn { var predicate = new TPredicate(); @@ -32,7 +32,7 @@ public static bool Invoke(in TClosure closure, return predicate.Invoke(in closure); } - public static bool Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + public static bool InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) where TPredicate : struct, IPredicateIn { var predicate = new TPredicate(); @@ -40,7 +40,7 @@ public static bool Invoke(in TClosure clos return predicate.Invoke(in closure); } - public static bool Invoke(in TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + public static bool InvokeIn(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) where TPredicate : struct, IPredicateIn { var predicate = new TPredicate(); @@ -117,5 +117,115 @@ public static bool Invoke(in TPredicat predicate.SetArguments(arg1, arg2, arg3, arg4, arg5); return predicate.Invoke(in closure); } + + public static bool InvokeIn(this TClosure closure, in T arg) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + return predicate.Invoke(in closure); + } + + public static bool InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(in closure); + } + + public static bool InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(in closure); + } + + public static bool InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(in closure); + } + + public static bool InvokeIn(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateInArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(in closure); + } + + public static bool Invoke(this TPredicate predicate, in TClosure closure, in T arg) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg); + return predicate.Invoke(in closure); + } + + public static bool Invoke(this TPredicate predicate, in TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(in closure); + } + + public static bool Invoke(this TPredicate predicate, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(in closure); + } + + public static bool Invoke(this TPredicate predicate, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(in closure); + } + + public static bool Invoke(this TPredicate predicate, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(in closure); + } + + public static bool Invoke(in TPredicate predicate, in TClosure closure, in T arg) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg); + return predicate.Invoke(in closure); + } + + public static bool Invoke(in TPredicate predicate, in TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(in closure); + } + + public static bool Invoke(in TPredicate predicate, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(in closure); + } + + public static bool Invoke(in TPredicate predicate, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(in closure); + } + + public static bool Invoke(in TPredicate predicate, in TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateInArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(in closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Predicate/ValuePredicate.PredicateRef.cs b/System.ValueDelegates/Predicate/ValuePredicate.PredicateRef.cs index aa6a2fa..e20b310 100644 --- a/System.ValueDelegates/Predicate/ValuePredicate.PredicateRef.cs +++ b/System.ValueDelegates/Predicate/ValuePredicate.PredicateRef.cs @@ -4,11 +4,11 @@ namespace System.ValueDelegates { public static partial class ValuePredicate { - public static bool InvokeRef(ref TClosure closure) + public static bool InvokeRef(this TClosure closure) where TPredicate : struct, IPredicateRef => new TPredicate().Invoke(ref closure); - public static bool InvokeRef(ref TClosure closure, T arg) + public static bool InvokeRef(this TClosure closure, T arg) where TPredicate : struct, IPredicateRef { var predicate = new TPredicate(); @@ -16,7 +16,7 @@ public static bool InvokeRef(ref TClosure closure, T ar return predicate.Invoke(ref closure); } - public static bool InvokeRef(ref TClosure closure, T1 arg1, T2 arg2) + public static bool InvokeRef(this TClosure closure, T1 arg1, T2 arg2) where TPredicate : struct, IPredicateRef { var predicate = new TPredicate(); @@ -24,7 +24,7 @@ public static bool InvokeRef(ref TClosure closure, return predicate.Invoke(ref closure); } - public static bool InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3) + public static bool InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3) where TPredicate : struct, IPredicateRef { var predicate = new TPredicate(); @@ -32,7 +32,7 @@ public static bool InvokeRef(ref TClosure clos return predicate.Invoke(ref closure); } - public static bool InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + public static bool InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4) where TPredicate : struct, IPredicateRef { var predicate = new TPredicate(); @@ -40,7 +40,7 @@ public static bool InvokeRef(ref TClosure return predicate.Invoke(ref closure); } - public static bool InvokeRef(ref TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + public static bool InvokeRef(this TClosure closure, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) where TPredicate : struct, IPredicateRef { var predicate = new TPredicate(); @@ -117,5 +117,115 @@ public static bool InvokeRef(in TPredi predicate.SetArguments(arg1, arg2, arg3, arg4, arg5); return predicate.Invoke(ref closure); } + + public static bool InvokeRef(this TClosure closure, in T arg) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateRefArgIn + { + var predicate = new TPredicate(); + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TPredicate predicate, ref TClosure closure, in T arg) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TPredicate predicate, ref TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TPredicate predicate, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TPredicate predicate, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(this TPredicate predicate, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(in TPredicate predicate, ref TClosure closure, in T arg) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(in TPredicate predicate, ref TClosure closure, in T1 arg1, in T2 arg2) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg1, in arg2); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(in TPredicate predicate, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(in TPredicate predicate, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4); + return predicate.Invoke(ref closure); + } + + public static bool InvokeRef(in TPredicate predicate, ref TClosure closure, in T1 arg1, in T2 arg2, in T3 arg3, in T4 arg4, in T5 arg5) + where TPredicate : struct, IPredicateRefArgIn + { + predicate.SetArguments(in arg1, in arg2, in arg3, in arg4, in arg5); + return predicate.Invoke(ref closure); + } } } \ No newline at end of file diff --git a/System.ValueDelegates/Predicate/ValuePredicate.cs b/System.ValueDelegates/Predicate/ValuePredicate.cs index 79321e6..7b96290 100644 --- a/System.ValueDelegates/Predicate/ValuePredicate.cs +++ b/System.ValueDelegates/Predicate/ValuePredicate.cs @@ -14,12 +14,6 @@ public ValuePredicate(TClosure closure) this.closure = closure; } - public ValuePredicate(in TClosure closure) - { - this.predicate = new TPredicate(); - this.closure = closure; - } - public ValuePredicate(TPredicate action, TClosure closure) { this.predicate = action; @@ -38,12 +32,6 @@ public ValuePredicate(in TPredicate action, TClosure closure) this.closure = closure; } - public ValuePredicate(in TPredicate action, in TClosure closure) - { - this.predicate = action; - this.closure = closure; - } - public bool Invoke() => this.predicate.Invoke(this.closure); }