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")]; }
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); }
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; }
public bool IsStrictEqual (JSValue value) { return JSValueIsStrictEqual (Context.Raw, Raw, value.Raw); }
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; }
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; }
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); }
public void SetProperty (string propertyName, JSValue value) { SetProperty (propertyName, value, JSPropertyAttribute.None); }
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 (); } }
internal JSException(JSContext context, JSValue error) : base("JSON: " + error.ToString ()) { Error = error; Context = context; }
protected virtual JSObject OnJSCallAsConstructor (JSObject constructor, JSValue [] args) { return null; }
public bool IsStrictEqual(JSValue value) { return(JSValueIsStrictEqual(Context.Raw, Raw, value.Raw)); }
protected override bool OnJSSetProperty(JSObject obj, string propertyName, JSValue value) { GetBag(obj)[propertyName] = value; return(true); }
protected override bool OnJSSetProperty(JSObject obj, string propertyName, JSValue value) { GetBag (obj)[propertyName] = value; return true; }
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; }