Ejemplo n.º 1
0
        internal async Task UpdateJavascriptObjects(bool debugMode)
        {
            await RunInJavascriptContext(async() =>
            {
                RegisterJavascriptHelper();

                Context.InitOnJsContext(debugMode);
                _SessionInjector = Context.JavascriptSessionInjector;

                _BuilderStrategy = _BuilderStrategyFactory.GetStrategy(Context.WebView, _SessionCache, Context.JavascriptFrameworkIsMappingObject);
                _BuilderStrategy.UpdateJavascriptValue(JsValueRoot);

                IJavascriptObject res;
                if (Context.JavascriptFrameworkIsMappingObject)
                {
                    res = await InjectInHtmlSession(JsValueRoot);
                }
                else
                {
                    res = JsValueRoot.JsValue;
                }

                await _SessionInjector.RegisterMainViewModel(res);

                _IsLoaded = true;
            });
        }
 internal JavascriptFrameworkRealMapper(HtmlViewContext context, IJavascriptSessionInjector sessionInjector, IInternalSessionCache sessionCache, IJavascriptObjectBuilderStrategy builderStrategy)
 {
     _SessionInjector = sessionInjector;
     _SessionCache    = sessionCache;
     _BuilderStrategy = builderStrategy;
     _Context         = context;
 }
Ejemplo n.º 3
0
 private void InitOnJavascriptContext(bool debugMode)
 {
     RegisterJavascriptHelper();
     Context.InitOnJsContext(debugMode);
     _SessionInjector = Context.JavascriptSessionInjector;
     _BuilderStrategy = _BuilderStrategyFactory.GetStrategy(Context.WebView, _SessionCache, Context.JavascriptFrameworkIsMappingObject);
     _BuilderStrategy.UpdateJavascriptValue(JsValueRoot);
 }
Ejemplo n.º 4
0
        internal async Task UpdateJavascriptObjects(bool debugMode)
        {
            await RunInJavascriptContext(async() =>
            {
                _Context.InitOnJsContext(debugMode);
                _sessionInjector = _Context.JavascriptSessionInjector;
                RegisterJavascriptHelper();
                _Root.ComputeJavascriptValue(_Context.WebView.Factory, _Context.ViewModelUpdater, _SessionCache);

                var res = await InjectInHTMLSession(_Root);
                await _sessionInjector.RegisterMainViewModel(res);

                _IsLoaded = true;
            });
        }
 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); 
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        internal async Task Init(object addicionalObject)
        {
            _Root = await _Context.EvaluateOnUIContextAsync(() => _JSObjectBuilder.InternalMap(_RootObject, addicionalObject));

            await RunInJavascriptContext(async() =>
            {
                _Context.InitOnJsContext();
                _sessionInjector = _Context.JavascriptSessionInjector;
                RegisterJavascriptHelper();
                _Root.ComputeJavascriptValue(_Context.WebView.Factory, _SessionCache);

                var res = await InjectInHTMLSession(_Root);

                await _sessionInjector.RegisterMainViewModel(res);

                if (ListenToCSharp)
                {
                    ListenToCSharpChanges();
                }
                _IsListening = true;
            });
        }