Exemplo n.º 1
0
        internal BidirectionalMapper(object root, HtmlViewEngine contextBuilder, IGlueFactory glueFactory, IJavascriptObjectBuilderStrategyFactory strategyFactory,
                                     JavascriptBindingMode mode, IInternalSessionCache sessionCacher)
        {
            Mode          = mode;
            Context       = contextBuilder.GetMainContext();
            _SessionCache = sessionCacher ?? new SessionCacher();

            strategyFactory  = strategyFactory ?? new StandardStrategyFactory();
            _BuilderStrategy = new Lazy <IJavascriptObjectBuilderStrategy>(() =>
                                                                           strategyFactory.GetStrategy(Context.WebView, _SessionCache, Context.JavascriptFrameworkIsMappingObject)
                                                                           );
            _JavascriptFrameworkManager = new Lazy <IJavascriptFrameworkMapper>(() => Context.GetMapper(_SessionCache, BuilderStrategy));

            var jsUpdateHelper = new JsUpdateHelper(this, Context, _JavascriptFrameworkManager, _SessionCache);

            _JavascriptToGlueMapper = new JavascriptToGlueMapper(jsUpdateHelper, _SessionCache);

            _CSharpChangesListener    = ListenToCSharp ? new CSharpListenerJavascriptUpdater(jsUpdateHelper) : null;
            glueFactory               = glueFactory ?? GlueFactoryFactory.GetFactory(Context, _SessionCache, _JavascriptToGlueMapper, _CSharpChangesListener?.On);
            _CSharpToGlueMapper       = new CSharpToGlueMapper(_SessionCache, glueFactory, Context.Logger);
            jsUpdateHelper.GlueMapper = _CSharpToGlueMapper;

            _CSharpUnrootedObjectManager      = new CSharpUnrootedObjectManager(jsUpdateHelper, _CSharpToGlueMapper);
            glueFactory.UnrootedObjectManager = _CSharpUnrootedObjectManager;
            _JavascriptChangesListener        = (Mode == JavascriptBindingMode.TwoWay) ?
                                                new JavascriptListenerCSharpUpdater(_CSharpChangesListener, jsUpdateHelper, _JavascriptToGlueMapper) : null;

            jsUpdateHelper.CheckUiContext();
            JsValueRoot = _CSharpToGlueMapper.Map(root);
            JsValueRoot.AddRef();
        }
Exemplo n.º 2
0
 public JsMappableResultCommand(HtmlViewContext context, ICSharpUnrootedObjectManager manager, IJavascriptToGlueMapper converter, IResultCommand <TArg, TResult> resultCommand)
     : base(context, manager, converter, resultCommand)
 {
 }
Exemplo n.º 3
0
 public JsResultCommand(HtmlViewContext context, ICSharpUnrootedObjectManager manager, IJavascriptToGlueMapper converter, IResultCommand <TResult> resultCommand) :
     base(context, manager, converter)
 {
     _JsResultCommand = resultCommand;
 }
 protected JsResultCommandBase(HtmlViewContext context, ICSharpUnrootedObjectManager manager, IJavascriptToGlueMapper converter)
 {
     _HtmlViewContext             = context;
     JavascriptToGlueMapper       = converter;
     _CSharpUnrootedObjectManager = manager;
 }