コード例 #1
0
 public void Dispose()
 {
     _Context.RunAsync(() =>
     {
         if (_JavascriptSessionInjector != null)
         {
             _JavascriptSessionInjector.Dispose();
             _JavascriptSessionInjector = null;
         }
     });
 }
コード例 #2
0
        public static async Task<IHTMLBinding> Bind(IHTMLWindow view, string iViewModel)
        {
            var context = view.MainFrame;

            var root = await context.EvaluateAsync(() =>
                {
                    var json = context.GetGlobal().GetValue("JSON");
                    return json.Invoke("parse", context, context.Factory.CreateString(iViewModel));
                });

            var injector = new JavascriptSessionInjector(context, null);
            var mappedroot = injector.Map(root, null);
            await injector.RegisterInSession(mappedroot);

            return new StringBinding(context, mappedroot, injector);
        }
コード例 #3
0
        public void Dispose()
        {
            WebCore.QueueWork(() =>
            {
                if (_CleanUp != null)
                {
                    _CleanUp();
                    _CleanUp = null;
                }

                if (_JavascriptSessionInjector != null)
                {
                    _JavascriptSessionInjector.Dispose();
                    _JavascriptSessionInjector = null;
                }
            }
                              );
        }
コード例 #4
0
        public static Task <IAwesomeBinding> Bind(IWebView view, string iViewModel, Action First = null, Action CleanUp = null)
        {
            TaskCompletionSource <IAwesomeBinding> tcs = new TaskCompletionSource <IAwesomeBinding>();

            view.ExecuteWhenReady(() =>
            {
                if (First != null)
                {
                    First();
                }
                JSObject json = view.ExecuteJavascriptWithResult("JSON");
                var root      = json.Invoke("parse", new JSValue(iViewModel));

                var injector   = new JavascriptSessionInjector(view, new GlobalBuilder(view, "MVVMGlue"), null);
                var mappedroot = injector.Map(root, null);
                injector.RegisterInSession(mappedroot);

                tcs.SetResult(new StringBinding(mappedroot, injector, CleanUp));
            });

            return(tcs.Task);
        }
コード例 #5
0
 internal StringBinding(JSObject root, JavascriptSessionInjector iJavascriptSessionInjector, Action CleanUp)
 {
     _JavascriptSessionInjector = iJavascriptSessionInjector;
     _CleanUp = CleanUp;
     _Root    = root;
 }
コード例 #6
0
 internal StringBinding(IWebView context, IJavascriptObject root, JavascriptSessionInjector iJavascriptSessionInjector)
 {
     _JavascriptSessionInjector = iJavascriptSessionInjector;
     _Context = context;
     _Root = root;
 }