示例#1
0
 public MarkdownService()
 {
     _ctx = new JSContext(_vm);
     var script = System.IO.File.ReadAllText("WebResources/marked.js", System.Text.Encoding.UTF8);
     _ctx.EvaluateScript(script);
     _val = _ctx[new NSString("marked")];
 }
示例#2
0
		public MarkdownService()
		{
            var scriptPath = System.IO.Path.Combine(NSBundle.MainBundle.BundlePath, "WebResources", "marked.js");
            var scriptContents = System.IO.File.ReadAllText(scriptPath);

            _ctx = new JSContext(_vm);
            _ctx.EvaluateScript(scriptContents);
			_val = _ctx[new NSString("marked")];
		}
        public void FetchMountedVolumes(JSValue jsOptions)
        {
            NSMutableArray volumes = GetMountedVolumes();
            JSValue[] args = new JSValue[] {JSValue.From(volumes, jsContext)};

            // not callable see Bug #17550
            // https://bugzilla.xamarin.com/show_bug.cgi?id=17550
            JSValue jsValueCallback = jsOptions.GetProperty("callback");

            // work-around for #17550
            JSValue workAroundCallback = jsContext[(NSString)"render"];
            workAroundCallback.Call(args);
        }
示例#4
0
        private IntPtr JSCallback (IntPtr ctx, IntPtr function, IntPtr thisObject,
            IntPtr argumentCount, IntPtr arguments, ref IntPtr exception)
        {
            var context = new JSContext (ctx);

            if (handler == null) {
                return JSValue.NewUndefined (context).Raw;
            }

            var args = new JSValue[argumentCount.ToInt32 ()];

            for (int i = 0; i < args.Length; i++) {
                args[i] = new JSValue (context, Marshal.ReadIntPtr (arguments, i * IntPtr.Size));
            }

            return handler (this, new JSObject (context, thisObject), args).Raw;
        }
示例#5
0
 public bool IsStrictEqual (JSValue value)
 {
     return JSValueIsStrictEqual (Context.Raw, Raw, value.Raw);
 }
示例#6
0
 public bool IsEqual (JSValue value)
 {
     var exception = IntPtr.Zero;
     var result = JSValueIsEqual (Context.Raw, Raw, value.Raw, ref exception);
     JSException.Proxy (Context, exception);
     return result;
 }
示例#7
0
文件: JSValue.cs 项目: knocte/banshee
 public static JSValue[] MarshalArray(IntPtr context, IntPtr items, IntPtr itemCount)
 {
     var array = new JSValue[itemCount.ToInt32 ()];
     for (int i = 0; i < array.Length; i++) {
         array[i] = new JSValue (context, Marshal.ReadIntPtr (items, i * IntPtr.Size));
     }
     return array;
 }
示例#8
0
 protected virtual bool OnJSSetProperty (JSObject obj, string propertyName, JSValue value)
 {
     return false;
 }
 public void fetchMountedVolumes(JSValue jsOptions)
 {
     NSMutableArray volumes = this.getMountedVolumes();
     JSValue jsCallback = jsOptions.valueForProperty("callback");
     jsCallback.callWithArguments(volumes);
 }
示例#10
0
 public void SetProperty (string propertyName, JSValue value)
 {
     SetProperty (propertyName, value, JSPropertyAttribute.None);
 }
示例#11
0
 public void SetProperty (string propertyName, JSValue value, JSPropertyAttribute attributes)
 {
     var exception = IntPtr.Zero;
     var property = JSString.New (propertyName);
     try {
         JSObjectSetProperty (Context.Raw, Raw, property, value.Raw, attributes, ref exception);
         JSException.Proxy (Context, exception);
     } finally {
         property.Release ();
     }
 }
示例#12
0
 internal JSException(JSContext context, JSValue error)
     : base("JSON: " + error.ToString ())
 {
     Error = error;
     Context = context;
 }
示例#13
0
 protected virtual JSObject OnJSCallAsConstructor (JSObject constructor, JSValue [] args)
 {
     return null;
 }
示例#14
0
 public bool IsStrictEqual(JSValue value)
 {
     return(JSValueIsStrictEqual(Context.Raw, Raw, value.Raw));
 }
示例#15
0
 protected override bool OnJSSetProperty(JSObject obj, string propertyName, JSValue value)
 {
     GetBag(obj)[propertyName] = value;
     return(true);
 }
示例#16
0
 protected override bool OnJSSetProperty(JSObject obj, string propertyName, JSValue value)
 {
     GetBag (obj)[propertyName] = value;
     return true;
 }
示例#17
0
        public JSValue CallAsFunction (JSObject thisObject, JSValue [] args)
        {
            var exception = IntPtr.Zero;
            var args_native = new IntPtr[args.Length];

            for (int i = 0; i < args.Length; i++) {
                args_native[i] = args[i].Raw;
            }

            var result = new JSValue (Context.Raw, JSObjectCallAsFunction (Context.Raw, Raw,
                thisObject == null ? IntPtr.Zero : thisObject.Raw, new IntPtr (args.Length),
                args_native, ref exception));

            JSException.Proxy (Context, exception);

            return result;
        }