using System; using System.Reflection; namespace UniJSON { public static partial class GenericInvokeCallFactory { //////////// StaticAction public static Action StaticAction(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (a0) => { m.Invoke(null, new object[] { a0 }); }; } public static Action StaticAction(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (a0, a1) => { m.Invoke(null, new object[] { a0, a1 }); }; } public static Action StaticAction(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (a0, a1, a2) => { m.Invoke(null, new object[] { a0, a1, a2 }); }; } public static Action StaticAction(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (a0, a1, a2, a3) => { m.Invoke(null, new object[] { a0, a1, a2, a3 }); }; } //////////// OpenAction public static Action OpenAction(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (s, a0) => { m.Invoke(s, new object[] { a0 }); }; } public static Action OpenAction(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (s, a0, a1) => { m.Invoke(s, new object[] { a0, a1 }); }; } public static Action OpenAction(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (s, a0, a1, a2) => { m.Invoke(s, new object[] { a0, a1, a2 }); }; } //////////// BindAction public static Action BindAction(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (a0) => { m.Invoke(instance, new object[] { a0 }); }; } public static Action BindAction(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (a0, a1) => { m.Invoke(instance, new object[] { a0, a1 }); }; } public static Action BindAction(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (a0, a1, a2) => { m.Invoke(instance, new object[] { a0, a1, a2 }); }; } public static Action BindAction(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (a0, a1, a2, a3) => { m.Invoke(instance, new object[] { a0, a1, a2, a3 }); }; } //////////// StaticFunc public static Func StaticFunc(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (a0) => (T)m.Invoke(null, new object[] { a0 }); } public static Func StaticFunc(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (a0, a1) => (T)m.Invoke(null, new object[] { a0, a1 }); } public static Func StaticFunc(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (a0, a1, a2) => (T)m.Invoke(null, new object[] { a0, a1, a2 }); } public static Func StaticFunc(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (a0, a1, a2, a3) => (T)m.Invoke(null, new object[] { a0, a1, a2, a3 }); } //////////// OpenFunc public static Func OpenFunc(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (s, a0) => (T)m.Invoke(s, new object[] { a0 }); } public static Func OpenFunc(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (s, a0, a1) => (T)m.Invoke(s, new object[] { a0, a1 }); } public static Func OpenFunc(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (s, a0, a1, a2) => (T)m.Invoke(s, new object[] { a0, a1, a2 }); } //////////// BindFunc public static Func BindFunc(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (a0) => (T)m.Invoke(instance, new object[] { a0 }); } public static Func BindFunc(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (a0, a1) => (T)m.Invoke(instance, new object[] { a0, a1 }); } public static Func BindFunc(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (a0, a1, a2) => (T)m.Invoke(instance, new object[] { a0, a1, a2 }); } public static Func BindFunc(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (a0, a1, a2, a3) => (T)m.Invoke(instance, new object[] { a0, a1, a2, a3 }); } } }