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 (Action)Delegate.CreateDelegate(typeof(Action), null, m); } public static Action StaticAction(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), null, m); } public static Action StaticAction(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), null, m); } public static Action StaticAction(MethodInfo m) { if (!m.IsStatic) { throw new ArgumentException(string.Format("{0} is not static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), null, m); } //////////// OpenAction public static Action OpenAction(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), m); } public static Action OpenAction(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), m); } public static Action OpenAction(MethodInfo m) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), m); } //////////// BindAction public static Action BindAction(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), instance, m); } public static Action BindAction(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), instance, m); } public static Action BindAction(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), instance, m); } public static Action BindAction(MethodInfo m, S instance) { if (m.IsStatic) { throw new ArgumentException(string.Format("{0} is static", m)); } return (Action)Delegate.CreateDelegate(typeof(Action), instance, m); } //////////// 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 }); } } }