lith 4 vuotta sitten
vanhempi
commit
807b587439
1 muutettua tiedostoa jossa 51 lisäystä ja 0 poistoa
  1. 51 0
      dotnet/Library/Vit/Vit.Core/Vit.Core/Util/MethodExt/Method.cs

+ 51 - 0
dotnet/Library/Vit/Vit.Core/Vit.Core/Util/MethodExt/Method.cs

@@ -0,0 +1,51 @@
+using System;
+
+namespace Vit.Core.Util.MethodExt
+{
+    public static class Method
+    {
+
+        #region Override
+        public static Func<Arg, Ret> Override<Arg, Ret>(Func<Arg, Ret> baseFunc, Func<Func<Arg, Ret>, Arg, Ret> thisFunc)
+        {
+            return (arg) =>
+            {
+                return thisFunc(baseFunc, arg);
+            };
+        }
+
+        public static Func<Ret> Override<Ret>(Func<Ret> baseFunc, Func<Func<Ret>, Ret> thisFunc)
+        {
+            return () =>
+            {
+                return thisFunc(baseFunc);
+            };
+        }
+        #endregion
+
+
+
+        #region  Wrap
+
+        public static void Wrap<Ret>(ref Func<Ret> baseFunc, Func<Func<Ret>, Ret> thisFunc)
+        {
+            var baseFunc_value = baseFunc;
+            baseFunc = () =>
+            {
+                return thisFunc(baseFunc_value);
+            };
+        }
+
+        public static void Wrap(ref Action baseFunc, Action<Action> thisFunc)
+        {
+            var baseFunc_value = baseFunc;
+            baseFunc = () =>
+            {
+                thisFunc(baseFunc_value);
+            };
+        }
+        #endregion
+
+
+    }
+}