示例#1
0
 private ClrFunctionInstance WrapDelegate(EchoDelegate _delegate)
 {
     return(Engine.AsJsFunction(new Func <JsValue, JsValue[], JsValue>((thisObject, args) => {
         _delegate(((args[0].IsNull() || args[0].IsUndefined()) ? null : ManticoreException.NativeInstanceForObject(args[0].AsObject())), Engine.Converter.AsNativeString(args[1]));
         return JsValue.Undefined;
     })));
 }
示例#2
0
        /**
         * Echo the argument via the callback
         */
        public void Echo(String arg, EchoDelegate callback)
        {
            JsValue[] args = new JsValue[] {
                Engine.Converter.AsJsString(arg),
                WrapDelegate(callback)
            };

            var func = this.impl.Get("echo").As <FunctionInstance>();

            Engine.Js(() => {
                func.Call(this.impl, args);
            });
        } /**
示例#3
0
 /**
  * Echo the argument via the callback after setTimeout(10)
  */
 public void EchoWithSetTimeout(String arg, EchoDelegate callback)
 {
     Engine.Js(() =>
               { this.impl.echoWithSetTimeout(Engine.Converter.AsJsString(arg),
                                              WrapDelegate(callback)); });
 }
示例#4
0
 private Action <dynamic, dynamic> WrapDelegate(EchoDelegate _delegate)
 {
     return(new Action <dynamic, dynamic>((error, arg) => {
         _delegate((Engine.IsNullOrUndefined(error) ? null : ManticoreException.NativeInstanceForObject(error)), Engine.Converter.AsNativeString(arg));
     }));
 }