Пример #1
0
 public void Dispose()
 {
     _Context.RunAsync(() =>
     {
         if (_JavascriptSessionInjector != null)
         {
             _JavascriptSessionInjector.Dispose();
             _JavascriptSessionInjector = null;
         }
     });
 }
Пример #2
0
        public static async Task<IHTMLBinding> Bind(ICefGlueWindow view, string iViewModel)
        {
            var context = view.MainFrame.GetMainContext();
            var v8context = context.Context;

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

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

            return new StringBinding(context, mappedroot, injector);
        }
Пример #3
0
        internal BidirectionalMapper(object iRoot, CefV8CompleteContext iwebview, JavascriptBindingMode iMode, object iadd)
        {
            _V8Context = iwebview;
            _LocalBuilder = new LocalBuilder(iwebview);
            _JSObjectBuilder = new CSharpToJavascriptMapper(iwebview, _LocalBuilder, this);
            _JavascriptToCSharpMapper = new JavascriptToCSharpMapper();
            _Root = _JSObjectBuilder.Map(iRoot, iadd);
            _UnrootedEntities = new List<IJSCSGlue>();
            _BindingMode = iMode;

            IJavascriptListener JavascriptObjecChanges = null;
            if (iMode == JavascriptBindingMode.TwoWay)
                JavascriptObjecChanges = this;

            _GlobalBuilder = new GlobalBuilder(_V8Context, "MVVMGlue");

            _SessionInjector = new JavascriptSessionInjector(iwebview, _GlobalBuilder, JavascriptObjecChanges);
        }
Пример #4
0
        public void Dispose()
        {
            if (ListenToCSharp)
                UnlistenToCSharpChanges();

            if (_SessionInjector != null)
            {
                _SessionInjector.Dispose();
                _SessionInjector = null;
            }

            _UnrootedEntities.Clear();
        }
Пример #5
0
 internal StringBinding(CefV8CompleteContext context, CefV8Value root, JavascriptSessionInjector iJavascriptSessionInjector)
 {
     _JavascriptSessionInjector = iJavascriptSessionInjector;
     _Context = context;
     _Root = root;
 }