[C#] Add initial hooks, the C# code compiles, the C not at all
[ldk-java] / c_sharp / src / org / ldk / util / InternalUtils.cs
diff --git a/c_sharp/src/org/ldk/util/InternalUtils.cs b/c_sharp/src/org/ldk/util/InternalUtils.cs
new file mode 100644 (file)
index 0000000..620b3b3
--- /dev/null
@@ -0,0 +1,25 @@
+using System;
+using org.ldk.util;
+
+internal class InternalUtils {
+       public static byte[] check_arr_len(byte[] arr, int length) {
+               if (arr != null && arr.Length != length) {
+                       throw new ArgumentException("Array must be of fixed size " + length + " but was of length " + arr.Length);
+               }
+               return arr;
+       }
+
+       public static byte[] convUInt5Array(UInt5[] u5s) {
+               byte[] res = new byte[u5s.Length];
+               for (int i = 0; i < u5s.Length; i++) {
+                       res[i] = u5s[i].getVal();
+               }
+               return res;
+       }
+
+       public static T[] mapArray<F, T>(F[] arr, Func<F, T> f) {
+               T[] ret = new T[arr.Length];
+               for (int i = 0; i < arr.Length; i++) ret[i] = f(arr[i]);
+               return ret;
+       }
+}