internal static async Task<IHTMLBinding> Bind(IHTMLWindowProvider windowprovider, object iViewModel, JavascriptBindingMode iMode, object additional = null) { var context = windowprovider.HTMLWindow.MainFrame; var mapper = await context.EvaluateAsync(() => new BidirectionalMapper(iViewModel, context, windowprovider.UIDispatcher, iMode, additional)); await mapper.Init(); return new HTML_Binding(context, mapper); }
internal static async Task<IHTMLBinding> Bind(ICefGlueWindow view, object iViewModel, JavascriptBindingMode iMode, object additional = null) { var context = view.MainFrame.GetMainContext(); var mapper = await context.EvaluateAsync(() => new BidirectionalMapper(iViewModel, context, iMode, additional)); await mapper.Init(); return new HTML_Binding(context, mapper); }
public Task Test_HTMLBinding_Stress_Collection_CreateBinding(JavascriptBindingMode imode, TestPerformanceKind context, TestContext ipath = TestContext.Index) { int r = 100; var datacontext = new TwoList(); datacontext.L1.AddRange(Enumerable.Range(0, r).Select(i => new Skill())); var stopWatch = new Stopwatch(); stopWatch.Start(); var test = new TestInContext() { Path = ipath, Bind = (win) => HTML_Binding.Bind(win, datacontext, imode), Test = (mb) => { stopWatch.Stop(); var ts = stopWatch.ElapsedMilliseconds; _Logger.Info($"Perf: {((double) (ts)) / 1000} sec for {r} iterations"); var js = mb.JSRootObject; var col = GetSafe(() => GetCollectionAttribute(js, "L1")); col.GetArrayLength().Should().Be(r); CheckVsExpectation(ts, context); } }; return RunAsync(test); }
internal static async Task<IHTMLBinding> Bind(HTMLViewEngine viewEngine, object iViewModel, JavascriptBindingMode iMode, object additional = null) { var mapper = viewEngine.GetMapper(iViewModel, iMode ); var res = new HTML_Binding(mapper, viewEngine.Logger); await mapper.Init(additional); return res; }
public Task<IHTMLBinding> NavigateAsync(object viewModel, string id = null, JavascriptBindingMode mode = JavascriptBindingMode.TwoWay) { if (IsLoaded) { return NavigateAsyncBase(viewModel, id, mode); } var taskCompletion = new TaskCompletionSource<IHTMLBinding>(); this.Loaded += (o,e) => HTMLWindow_Loaded(taskCompletion, viewModel, id, mode); return taskCompletion.Task; }
private async void HTMLWindow_Loaded(TaskCompletionSource<IHTMLBinding> taskCompletion, object viewModel, string id, JavascriptBindingMode mode) { try { var res = await NavigateAsyncBase(viewModel, id, mode); taskCompletion.TrySetResult(res); } catch(Exception ex) { taskCompletion.SetException(ex); } }
internal BidirectionalMapper(object iRoot, IWebView iwebview, IDispatcher UIDispatcher, JavascriptBindingMode iMode, object iadd) { _IWebView = iwebview; _JSObjectBuilder = new CSharpToJavascriptMapper(iwebview,UIDispatcher, this); _Root = _JSObjectBuilder.Map(iRoot, iadd); _UnrootedEntities = new List<IJSCSGlue>(); _BindingMode = iMode; IJavascriptListener JavascriptObjecChanges = null; if (iMode == JavascriptBindingMode.TwoWay) JavascriptObjecChanges = this; _SessionInjector = new JavascriptSessionInjector(iwebview, JavascriptObjecChanges); }
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); }
internal BidirectionalMapper(object iRoot, HTMLViewEngine contextBuilder, JavascriptBindingMode iMode, object addicionalObject, IWebSessionLogger logger) { _BindingMode = iMode; _Logger = logger; var javascriptObjecChanges = (iMode == JavascriptBindingMode.TwoWay) ? (IJavascriptChangesObserver)this : null; _Context = contextBuilder.GetMainContext(javascriptObjecChanges); _sessionInjector = _Context.JavascriptSessionInjector; _SessionCache = new SessionCacher(); _ListenerRegister = new FullListenerRegister( (n) => n.PropertyChanged += CSharpPropertyChanged, (n) => n.PropertyChanged -= CSharpPropertyChanged, (n) => n.CollectionChanged += CSharpCollectionChanged, (n) => n.CollectionChanged -= CSharpCollectionChanged, (c) => c.ListenChanges(), (c) => c.UnListenChanges()); var commandFactory = new CommandFactory(_Context, this); RegisterJavascriptHelper(); _JSObjectBuilder = new CSharpToJavascriptConverter(_Context, _SessionCache, commandFactory, _Logger) ; _Root = _JSObjectBuilder.Map(iRoot, addicionalObject); }
internal static Task<IAwesomeBinding> Bind(IWebView view, object iViewModel, object additional, JavascriptBindingMode iMode, Action First, Action CleanUp) { TaskCompletionSource<IAwesomeBinding> tcs = new TaskCompletionSource<IAwesomeBinding>(); view.ExecuteWhenReady(() => { try { if (First != null) First(); var mapper = new BidirectionalMapper(iViewModel, view, iMode, additional); mapper.Init().ContinueWith(_ => tcs.SetResult(new AwesomeBinding(mapper, CleanUp))); } catch (Exception e) { tcs.SetException(e); } }); return tcs.Task; }
internal BidirectionalMapper GetMapper(object viewModel, JavascriptBindingMode mode, IJavascriptObjectBuilderStrategyFactory strategyFactory) { return(new BidirectionalMapper(viewModel, this, mode, Logger, strategyFactory)); }
private Task<IHTMLBinding> Navigate(Uri uri, object iViewModel, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { if (uri == null) throw ExceptionHelper.GetArgument($"ViewModel not registered: {iViewModel.GetType()}"); _Navigating = true; var oldvm = Binding?.Root as INavigable; if (_UseINavigable && (oldvm!=null)) { oldvm.Navigation = null; } var wh = new WindowHelper(new HTMLLogicWindow()); if (_CurrentWebControl != null) _CurrentWebControl.HTMLWindow.Crashed -= Crashed; var closetask = ( _CurrentWebControl!=null) ? _Window.CloseAsync() : TaskHelper.Ended(); _NextWebControl = _WebViewLifeCycleManager.Create(); _NextWebControl.HTMLWindow.ConsoleMessage += ConsoleMessage; var moderWindow = _NextWebControl.HTMLWindow as IModernWebBrowserWindow; if (moderWindow!=null) { var debugContext = _WebViewLifeCycleManager.DebugContext; EventHandler<BeforeJavascriptExcecutionArgs> before = null; before = (o,e) => { moderWindow.BeforeJavascriptExecuted -= before; e.JavascriptExecutor(_javascriptFrameworkManager.GetMainScript(debugContext)); }; moderWindow.BeforeJavascriptExecuted += before; } var tcs = new TaskCompletionSource<IHTMLBinding>(); EventHandler<LoadEndEventArgs> sourceupdate = null; sourceupdate = (o, e) => { var injectorFactory = GetInjectorFactory(uri); _NextWebControl.HTMLWindow.LoadEnd -= sourceupdate; var engine = new HTMLViewEngine(_NextWebControl, injectorFactory, _webSessionLogger); HTML_Binding.Bind(engine, iViewModel, iMode, wh).WaitWith(closetask, t => Switch(t, wh.__window__, tcs)); }; Url = uri; _NextWebControl.HTMLWindow.LoadEnd += sourceupdate; _NextWebControl.HTMLWindow.NavigateTo(uri); return tcs.Task; }
private Task <IHtmlBinding> Navigate(Uri uri, object viewModel, JavascriptBindingMode mode = JavascriptBindingMode.TwoWay) { if (uri == null) { throw ExceptionHelper.GetArgument($"ViewModel not registered: {viewModel.GetType()}"); } _Navigating = true; var oldvm = GetMainViewModel(Binding) as INavigable; if (_UseINavigable && (oldvm != null)) { oldvm.Navigation = null; } if (_CurrentWebControl != null) { _CurrentWebControl.HtmlWindow.Crashed -= Crashed; } var closetask = (_CurrentWebControl != null) ? _Window.CloseAsync() : TaskHelper.Ended(); _NextWebControl = _WebViewLifeCycleManager.Create(); _NextWebControl.HtmlWindow.ConsoleMessage += ConsoleMessage; var moderWindow = _NextWebControl.HtmlWindow as IModernWebBrowserWindow; var injectorFactory = GetInjectorFactory(uri); var engine = new HtmlViewEngine(_NextWebControl, injectorFactory, _webSessionLogger); var dataContext = new DataContextViewModel(viewModel); var initVm = HtmlBinding.GetBindingBuilder(engine, dataContext, mode); if (moderWindow != null) { var debugContext = _WebViewLifeCycleManager.DebugContext; EventHandler <BeforeJavascriptExcecutionArgs> before = null; before = (o, e) => { moderWindow.BeforeJavascriptExecuted -= before; e.JavascriptExecutor(_JavascriptFrameworkManager.GetMainScript(debugContext)); }; moderWindow.BeforeJavascriptExecuted += before; } var tcs = new TaskCompletionSource <IHtmlBinding>(); EventHandler <LoadEndEventArgs> sourceupdate = null; sourceupdate = async(o, e) => { _NextWebControl.HtmlWindow.LoadEnd -= sourceupdate; var builder = await initVm; await builder.CreateBinding(_WebViewLifeCycleManager.DebugContext).WaitWith(closetask, t => Switch(t, dataContext.Window, tcs)).ConfigureAwait(false); }; Url = uri; _NextWebControl.HtmlWindow.LoadEnd += sourceupdate; _NextWebControl.HtmlWindow.NavigateTo(uri); return(tcs.Task); }
protected Task NavigateAsyncBase(object iViewModel, string Id = null, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { return _WPFDoubleBrowserNavigator.NavigateAsync(iViewModel, Id, iMode); }
internal BidirectionalMapper(object root, HtmlViewEngine contextBuilder, JavascriptBindingMode mode, IWebSessionLogger logger, IJavascriptObjectBuilderStrategyFactory strategyFactory) : this(root, contextBuilder, null, strategyFactory, mode, logger) { }
internal static async Task <IHTMLBinding> Bind(IHTMLWindowProvider windowprovider, object iViewModel, JavascriptBindingMode iMode, object additional = null) { var context = windowprovider.HTMLWindow.MainFrame; var mapper = await context.EvaluateAsync(() => new BidirectionalMapper(iViewModel, context, windowprovider.UIDispatcher, iMode, additional)); await mapper.Init(); return(new HTML_Binding(context, mapper)); }
public Task NavigateAsync(object iViewModel, string Id = null, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { return NavigateAsyncBase(iViewModel, Id, iMode); }
protected Task <IHtmlBinding> Bind(HtmlViewEngine engine, object dataContext, JavascriptBindingMode mode = JavascriptBindingMode.TwoWay) { return(HtmlBinding.Bind(engine, dataContext, mode)); }
public Task<IAwesomeBinding> Bind(IWebView view, object iViewModel, object addinfo, JavascriptBindingMode iMode) { return AwesomeBinding.Bind(view, iViewModel, addinfo, iMode, GetFirst(view), GetLast(view)); }
public Task Navigate(Uri iUri, object iViewModel, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { if (iUri == null) throw ExceptionHelper.GetArgument(string.Format("ViewModel not registered: {0}", iViewModel.GetType())); _Navigating = true; INavigable oldvm = (Binding != null) ? Binding.Root as INavigable : null; if (_UseINavigable && (oldvm!=null)) { oldvm.Navigation = null; } var wh = new WindowHelper(new HTMLLogicWindow()); if (_CurrentWebControl != null) _CurrentWebControl.Crashed -= Crashed; Task closetask = ( _CurrentWebControl!=null) ? _Window.CloseAsync() : TaskHelper.Ended(); _NextWebControl = _IWebViewLifeCycleManager.Create(); _NextWebControl.ConsoleMessage += ConsoleMessage; TaskCompletionSource<IAwesomeBinding> tcs = new TaskCompletionSource<IAwesomeBinding>(); UrlEventHandler sourceupdate = null; sourceupdate = (o, e) => { _NextWebControl.AddressChanged -= sourceupdate; _IAwesomiumBindingFactory.Bind(_NextWebControl, iViewModel, wh, iMode).WaitWith(closetask, t => Switch(t, wh.__window__, tcs)); }; _NextWebControl.AddressChanged += sourceupdate; if (_NextWebControl.Source == iUri) _NextWebControl.Reload(false); else _NextWebControl.Source = iUri; return tcs.Task; }
internal static IBindingBuilder GetBindingBuilder(HtmlViewEngine viewEngine, object viewModel, JavascriptBindingMode mode, IJavascriptObjectBuilderStrategyFactory strategyFactory = null) { var mapper = viewEngine.GetMapper(viewModel, mode, strategyFactory); return(new BindingBuilder(mapper)); }
internal static async Task <IHtmlBinding> Bind(HtmlViewEngine viewEngine, object viewModel, JavascriptBindingMode mode) { var builder = GetBindingBuilder(viewEngine, viewModel, mode); return(await builder.CreateBinding(false)); }
public static Task<IAwesomeBinding> Bind(IWebView view, object iViewModel, JavascriptBindingMode iMode) { return Bind(view, iViewModel, null, iMode, null, null); }
public Task NavigateAsync(object iViewModel, string Id = null, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { if ((iViewModel == null) || (_Navigating)) return TaskHelper.Ended(); return Navigate(_INavigationBuilder.Solve(iViewModel, Id).LocalPath, iViewModel, iMode); }
public Task <IAwesomeBinding> Bind(IWebView view, object iViewModel, object addinfo, JavascriptBindingMode iMode) { return(AwesomeBinding.Bind(view, iViewModel, addinfo, iMode, GetFirst(view), GetLast(view))); }
protected async Task <IHtmlBinding> Bind(HtmlViewEngine engine, object dataContext, JavascriptBindingMode mode = JavascriptBindingMode.TwoWay) { var withContext = await BindInContext(engine, dataContext, mode); return(withContext.Binding); }
private Task <IHTMLBinding> Navigate(Uri uri, object iViewModel, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { if (uri == null) { throw ExceptionHelper.GetArgument($"ViewModel not registered: {iViewModel.GetType()}"); } _Navigating = true; var oldvm = Binding?.Root as INavigable; if (_UseINavigable && (oldvm != null)) { oldvm.Navigation = null; } var wh = new WindowHelper(new HTMLLogicWindow()); if (_CurrentWebControl != null) { _CurrentWebControl.HTMLWindow.Crashed -= Crashed; } var closetask = (_CurrentWebControl != null) ? _Window.CloseAsync() : TaskHelper.Ended(); _NextWebControl = _WebViewLifeCycleManager.Create(); _NextWebControl.HTMLWindow.ConsoleMessage += ConsoleMessage; var moderWindow = _NextWebControl.HTMLWindow as IModernWebBrowserWindow; if (moderWindow != null) { var debugContext = _WebViewLifeCycleManager.DebugContext; EventHandler <BeforeJavascriptExcecutionArgs> before = null; before = (o, e) => { moderWindow.BeforeJavascriptExecuted -= before; e.JavascriptExecutor(_javascriptFrameworkManager.GetMainScript(debugContext)); }; moderWindow.BeforeJavascriptExecuted += before; } var tcs = new TaskCompletionSource <IHTMLBinding>(); EventHandler <LoadEndEventArgs> sourceupdate = null; sourceupdate = (o, e) => { var injectorFactory = GetInjectorFactory(uri); _NextWebControl.HTMLWindow.LoadEnd -= sourceupdate; var engine = new HTMLViewEngine(_NextWebControl, injectorFactory, _webSessionLogger); HTML_Binding.Bind(engine, iViewModel, iMode, wh).WaitWith(closetask, t => Switch(t, wh.__window__, tcs)); }; Url = uri; _NextWebControl.HTMLWindow.LoadEnd += sourceupdate; _NextWebControl.HTMLWindow.NavigateTo(uri); return(tcs.Task); }
protected async Task <BindingInContext> BindInContext(HtmlViewEngine engine, object dataContext, JavascriptBindingMode mode = JavascriptBindingMode.TwoWay) { var cacher = new SessionCacher(); var mapper = new BidirectionalMapper(dataContext, engine, null, null, mode, cacher); var builder = new BindingBuilder(mapper) as IBindingBuilder; var binding = await builder.CreateBinding(false); return(new BindingInContext(binding, cacher)); }
internal BidirectionalMapper(object root, HtmlViewEngine engine, JavascriptBindingMode mode, IJavascriptObjectBuilderStrategyFactory strategyFactory) : this(root, engine, null, strategyFactory, mode, null) { }
internal BidirectionalMapper(object root, HTMLViewEngine contextBuilder, IGlueFactory glueFactory, IJavascriptObjectBuilderStrategyFactory strategyFactory, JavascriptBindingMode mode, IWebSessionLogger logger) { _BuilderStrategyFactory = strategyFactory ?? new StandardStrategyFactory(); _BindingMode = mode; _Logger = logger; var javascriptObjecChanges = (mode == JavascriptBindingMode.TwoWay) ? (IJavascriptChangesObserver)this : null; _Context = contextBuilder.GetMainContext(javascriptObjecChanges); _SessionCache = new SessionCacher(); _ListenerRegister = new FullListenerRegister( (n) => n.PropertyChanged += CSharpPropertyChanged, (n) => n.PropertyChanged -= CSharpPropertyChanged, (n) => n.CollectionChanged += CSharpCollectionChanged, (n) => n.CollectionChanged -= CSharpCollectionChanged, (c) => c.ListenChanges(), (c) => c.UnListenChanges()); glueFactory = glueFactory ?? GlueFactoryFactory.GetFactory(_Context, this); _JSObjectBuilder = new CSharpToJavascriptConverter(contextBuilder.HTMLWindow, _SessionCache, glueFactory, _Logger); _RootObject = root; }
internal BidirectionalMapper(object root, HtmlViewEngine contextBuilder, IGlueFactory glueFactory, IJavascriptObjectBuilderStrategyFactory strategyFactory, JavascriptBindingMode mode, IWebSessionLogger logger) { _BuilderStrategyFactory = strategyFactory ?? new StandardStrategyFactory(); Mode = mode; _Logger = logger; var javascriptObjecChanges = (mode == JavascriptBindingMode.TwoWay) ? (IJavascriptChangesObserver)this : null; Context = contextBuilder.GetMainContext(javascriptObjecChanges); _SessionCache = new SessionCacher(); _ListenerRegister = ListenToCSharp ? new FullListenerRegister(OnCSharpPropertyChanged, OnCSharpCollectionChanged): null; glueFactory = glueFactory ?? GlueFactoryFactory.GetFactory(Context, _SessionCache, this, _ListenerRegister?.On); _JsObjectBuilder = new CSharpToJavascriptConverter(_SessionCache, glueFactory, _Logger); _RootObject = root; }
public Task NavigateAsync(object iViewModel, string Id = null, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { return(NavigateAsyncBase(iViewModel, Id, iMode)); }
protected Task NavigateAsyncBase(object iViewModel, string Id = null, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { return(_WPFDoubleBrowserNavigator.NavigateAsync(iViewModel, Id, iMode)); }
internal BidirectionalMapper GetMapper(object viewModel, JavascriptBindingMode mode) { return(new BidirectionalMapper(viewModel, this, mode, Logger)); }
public async Task <IHtmlBinding> NavigateAsync(object viewModel, string id = "", JavascriptBindingMode mode = JavascriptBindingMode.TwoWay) { if ((viewModel == null) || (_Navigating)) { return(null); } var viewPath = _UrlSolver.Solve(viewModel, id); if (viewPath == null) { throw ExceptionHelper.Get($"Unable to locate ViewModel {viewModel}"); } return(await Navigate(viewPath, viewModel, mode)); }
internal static async Task <IHTMLBinding> Bind(HTMLViewEngine viewEngine, object iViewModel, JavascriptBindingMode iMode, object additional = null) { var mapper = viewEngine.GetMapper(iViewModel, iMode, additional); var res = new HTML_Binding(mapper, viewEngine.Logger); await viewEngine.Evaluate(() => mapper.Init()); return(res); }
public async Task<IHTMLBinding> NavigateAsync(object iViewModel, string id = null,JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { if ((iViewModel == null) || (_Navigating)) return null; var viewPath = _UrlSolver.Solve(iViewModel, id); if (viewPath == null) throw ExceptionHelper.Get($"Unable to locate ViewModel {iViewModel}"); return await Navigate(viewPath, iViewModel, iMode); }
internal static async Task <IHTMLBinding> Bind(HTMLViewEngine viewEngine, object viewModel, JavascriptBindingMode mode, object additional = null) { var builder = await GetBindingBuilder(viewEngine, viewModel, mode, additional); return(await builder.CreateBinding(false)); }
//private void Crashed(object sender, CrashedEventArgs e) //{ // if ((WebCore.IsShuttingDown) || (!WebCore.IsInitialized) || (Application.Current==null)) // return; // var dest = _CurrentWebControl.Source; // var vm = Binding.Root; // LogCritical("WebView crashed trying recover"); // _IWebViewLifeCycleManager.Dispose(_CurrentWebControl); // _CurrentWebControl.ConsoleMessage -= ConsoleMessage; // _CurrentWebControl.Crashed -= Crashed; // _CurrentWebControl = null; // Binding = null; // WebCore.QueueWork(() => Navigate(dest, vm, JavascriptBindingMode.TwoWay)); //} public Task Navigate(string iUri, object iViewModel, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { if (iUri == null) throw ExceptionHelper.GetArgument(string.Format("ViewModel not registered: {0}", iViewModel.GetType())); _Navigating = true; INavigable oldvm = (Binding != null) ? Binding.Root as INavigable : null; if (_UseINavigable && (oldvm!=null)) { oldvm.Navigation = null; } var wh = new WindowHelper(new HTMLLogicWindow()); //if (_CurrentWebControl != null) // _CurrentWebControl.Crashed -= Crashed; Task closetask = ( _CurrentWebControl!=null) ? _Window.CloseAsync() : TaskHelper.Ended(); _NextWebControl = _IWebViewLifeCycleManager.Create(); _NextWebControl.ConsoleMessage += ConsoleMessage; TaskCompletionSource<IHTMLBinding> tcs = new TaskCompletionSource<IHTMLBinding>(); EventHandler<LoadEndEventArgs> sourceupdate = null; sourceupdate = (o, e) => { _NextWebControl.LoadEnd -= sourceupdate; HTML_Binding.Bind(_NextWebControl, iViewModel, iMode, wh). WaitWith(closetask, t => Switch(t, wh.__window__, tcs)); }; _NextWebControl.LoadEnd += sourceupdate; _NextWebControl.NavigateTo(iUri); return tcs.Task; }
internal static async Task <IHTMLBinding> Bind(HTMLViewEngine viewEngine, object viewModel, JavascriptBindingMode mode, IJavascriptObjectBuilderStrategyFactory strategyFactory) { var builder = await GetBindingBuilder(viewEngine, viewModel, mode, null, strategyFactory); return(await builder.CreateBinding(false)); }
internal BidirectionalMapper(object root, HtmlViewEngine contextBuilder, IGlueFactory glueFactory, IJavascriptObjectBuilderStrategyFactory strategyFactory, JavascriptBindingMode mode, IWebSessionLogger logger) { _BuilderStrategyFactory = strategyFactory ?? new StandardStrategyFactory(); Mode = mode; _Logger = logger; var javascriptObjecChanges = (mode == JavascriptBindingMode.TwoWay) ? (IJavascriptChangesObserver)this : null; Context = contextBuilder.GetMainContext(javascriptObjecChanges); _SessionCache = new SessionCacher(); var jsUpdateHelper = new JsUpdateHelper(this, Context, () => _BuilderStrategy, _SessionCache); _ListenerUpdater = ListenToCSharp ? new ListenerUpdater(jsUpdateHelper) : null; glueFactory = glueFactory ?? GlueFactoryFactory.GetFactory(Context, _SessionCache, this, _ListenerUpdater?.On); _JsObjectBuilder = new CSharpToJavascriptConverter(_SessionCache, glueFactory, _Logger); jsUpdateHelper.JsObjectBuilder = _JsObjectBuilder; _JsUpdateHelper = jsUpdateHelper; _RootObject = root; _JsUpdateHelper.CheckUiContext(); JsValueRoot = _JsObjectBuilder.Map(_RootObject); JsValueRoot.AddRef(); }
internal static async Task <IBindingBuilder> GetBindingBuilder(HTMLViewEngine viewEngine, object viewModel, JavascriptBindingMode mode, object additional = null, IJavascriptObjectBuilderStrategyFactory strategyFactory = null) { var mapper = viewEngine.GetMapper(viewModel, mode, strategyFactory); var bindingBuilder = new BindingBuilder(mapper, viewEngine.Logger, additional); await bindingBuilder.Init(); return(bindingBuilder); }
public async Task<IHTMLBinding> NavigateAsync(object iViewModel, string id = null, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { return await NavigateAsyncBase(iViewModel, id, iMode); }
protected async Task <IHTMLBinding> NavigateAsyncBase(object iViewModel, string Id = "", JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { return(await WPFDoubleBrowserNavigator.NavigateAsync(iViewModel, Id, iMode)); }
private async void HTMLWindow_Initialized(TaskCompletionSource <IHTMLBinding> taskCompletion, object viewModel, string id, JavascriptBindingMode mode) { try { var res = await NavigateAsyncBase(viewModel, id, mode); taskCompletion.TrySetResult(res); } catch (Exception ex) { taskCompletion.SetException(ex); } }
public async Task <IHTMLBinding> NavigateAsync(object iViewModel, string id = null, JavascriptBindingMode iMode = JavascriptBindingMode.TwoWay) { return(await NavigateAsyncBase(iViewModel, id, iMode)); }