Пример #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")];
		}
Пример #3
0
        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
 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;
 }
Пример #9
0
 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;
        }