예제 #1
0
        public static JsObject BuildDelegateFunction(JsGlobal global, Delegate @delegate)
        {
            if (global == null)
                throw new ArgumentNullException("global");
            if (@delegate == null)
                throw new ArgumentNullException("delegate");

            return global.CreateFunction(
                @delegate.Method.Name,
                WrapDelegate(@delegate),
                @delegate.Method.GetParameters().Length
            );
        }
예제 #2
0
        public static JsObject BuildMethodFunction(JsGlobal global, MethodInfo method)
        {
            if (method == null)
                throw new ArgumentNullException("method");
            if (global == null)
                throw new ArgumentNullException("global");
            if (method.ContainsGenericParameters)
                throw new InvalidOperationException("Can't wrap an unclosed generic");

            return global.CreateFunction(
                method.Name,
                WrapMethod(method),
                method.GetParameters().Length
            );
        }