Exemplo n.º 1
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);
        }