Пример #1
0
        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;
        }
        protected override void Init()
        {
            _ICSharpMapper = Substitute.For<IJavascriptSessionCache>();
            _JSCommandFactory = Substitute.For<IJSCommandFactory>();
            _ICSharpMapper.GetCached(Arg.Any<object>()).Returns((IJSCSGlue)null);
            _javascriptFrameworkManager = Substitute.For<IJavascriptFrameworkManager>();
            _HTMLViewContext = new HTMLViewContext(_WebView, GetTestUIDispacther(), _javascriptFrameworkManager, null, _Logger);         
            _ConverTOJSO = new CSharpToJavascriptConverter(_HTMLViewContext, _ICSharpMapper, _JSCommandFactory, _Logger);
            _Test = new TestClass { S1 = "string", I1 = 25 };
            _Tests = new List<TestClass>
            {
                new TestClass() {  S1 = "string1", I1 = 1 },
                new TestClass() { S1 = "string2", I1 = 2  }
            };
            _Test2 = new Test2() { T1 = _Test, T2 = _Test };

            _Tests_NG = new ArrayList();
            _Tests_NG.Add(_Tests[0]);
            _Tests_NG.Add(_Tests[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); 
 }
Пример #4
0
        internal BidirectionalMapper(object iRoot, HTMLViewEngine contextBuilder, JavascriptBindingMode iMode, IWebSessionLogger logger)
        {
            _BindingMode = iMode;
            _Logger      = logger;
            var javascriptObjecChanges = (iMode == 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());
            var commandFactory = new CommandFactory(_Context, this);

            _JSObjectBuilder = new CSharpToJavascriptConverter(contextBuilder.HTMLWindow, _SessionCache, commandFactory, _Logger);
            _RootObject      = iRoot;
        }
Пример #5
0
        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;
        }
Пример #6
0
        internal BidirectionalMapper(object root, HtmlViewEngine contextBuilder, IGlueFactory glueFactory,
                                     IJavascriptObjectBuilderStrategyFactory strategyFactory, JavascriptBindingMode mode, IWebSessionLogger logger)
        {
            _BuilderStrategyFactory = strategyFactory ?? new StandardStrategyFactory();
            Mode    = mode;
            _Logger = logger;
            var javascriptObjectChanges = (mode == JavascriptBindingMode.TwoWay) ? (IJavascriptChangesObserver)this : null;

            Context       = contextBuilder.GetMainContext(javascriptObjectChanges);
            _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();
        }