Пример #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();
        }
Пример #2
0
 internal JsCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommand command) :
     base(context, converter)
 {
     _Command = command;
     try
     {
         _CanExecute = _Command.CanExecute(null);
     }
     catch { }
 }
Пример #3
0
 private static object GetArgument(this IJavascriptToGlueMapper converter, IJavascriptObject javascriptObject, Type targetType)
 {
     try
     {
         return(converter.GetGlueConvertible(javascriptObject, targetType).Source);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Пример #4
0
        internal static MayBe <T> GetFirstArgument <T>(this IJavascriptToGlueMapper converter, IJavascriptObject[] javascriptObjects)
        {
            if (javascriptObjects.Length == 0)
            {
                return(new MayBe <T>());
            }

            var argument = javascriptObjects[0];

            if (argument == null)
            {
                return(new MayBe <T>());
            }

            try
            {
                var found = converter.GetGlueConvertible(argument, typeof(T));
                return(new MayBe <T>(found.Source));
            }
            catch (Exception)
            {
                return(new MayBe <T>());
            }
        }
Пример #5
0
 public JsSimpleCommandBase(HtmlViewContext context, IJavascriptToGlueMapper converter)
 {
     _HtmlViewContext       = context;
     JavascriptToGlueMapper = converter;
 }
Пример #6
0
 public JsResultCommand(HtmlViewContext context, ICSharpUnrootedObjectManager manager, IJavascriptToGlueMapper converter, IResultCommand <TResult> resultCommand) :
     base(context, manager, converter)
 {
     _JsResultCommand = resultCommand;
 }
Пример #7
0
 public JsSimpleCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ISimpleCommand simpleCommand) :
     base(context, converter)
 {
     _JsSimpleCommand = simpleCommand;
 }
 public JsMappableSimpleCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ISimpleCommand resultCommand)
     : base(context, converter, resultCommand)
 {
 }
Пример #9
0
 protected internal JsCommandBase(HtmlViewContext context, IJavascriptToGlueMapper converter)
 {
     JavascriptToGlueMapper = converter;
     _HtmlViewContext       = context;
 }
Пример #10
0
 public GlueMappingFactory(HtmlViewContext context, ICSharpToJsCache cacher, IJavascriptToGlueMapper converter, ObjectChangesListener onListener) :
     base(cacher, onListener)
 {
     _HtmlViewContext        = context;
     _JavascriptToGlueMapper = converter;
 }
Пример #11
0
 public JsMappableCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommand command) :
     base(context, converter, command)
 {
 }
Пример #12
0
 internal JsCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommand <T> command) :
     base(context, converter)
 {
     _Command    = command;
     _CanExecute = true;
 }
Пример #13
0
 internal IndividualCollectionChange(IndividualJavascriptCollectionChange change, IJavascriptToGlueMapper mapper, Type targetType)
 {
     CollectionChangeType = change.CollectionChangeType;
     Index   = change.Index;
     Mapable = mapper.GetGlueConvertible(change.Object, targetType);
 }
Пример #14
0
 public CollectionChanges.CollectionChanges GetChanger(JavascriptCollectionChanges changes, IJavascriptToGlueMapper bridge)
 {
     return(new CollectionChanges.CollectionChanges(bridge, changes, _IndividualType));
 }
Пример #15
0
 public JsMappableResultCommand(HtmlViewContext context, ICSharpUnrootedObjectManager manager, IJavascriptToGlueMapper converter, IResultCommand <TArg, TResult> resultCommand)
     : base(context, manager, converter, resultCommand)
 {
 }
Пример #16
0
 internal static object GetFirstArgumentOrNull(this IJavascriptToGlueMapper converter, IJavascriptObject[] javascriptObjects)
 {
     return(javascriptObjects.Length == 0 ? null : converter.GetArgument(javascriptObjects[0], null));
 }
Пример #17
0
        internal static IGlueFactory GetFactory(HtmlViewContext context, ICSharpToJsCache cacher, IJavascriptToGlueMapper converter, ObjectChangesListener onListener)
        {
            var isMapping = context.JavascriptFrameworkIsMappingObject;

            return(isMapping ? (IGlueFactory) new GlueMappingFactory(context, cacher, converter, onListener) : new GlueFactory(context, cacher, converter, onListener));
        }
 public JsMappedCommandWithoutParameter(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommandWithoutParameter command)
     : base(context, converter, command)
 {
 }
 protected JsResultCommandBase(HtmlViewContext context, ICSharpUnrootedObjectManager manager, IJavascriptToGlueMapper converter)
 {
     _HtmlViewContext             = context;
     JavascriptToGlueMapper       = converter;
     _CSharpUnrootedObjectManager = manager;
 }
Пример #20
0
 internal CollectionChanges(IJavascriptToGlueMapper jsCsBridgeCache, JavascriptCollectionChanges changes, Type targetedType)
 {
     IndividualChanges = changes.Changes
                         .Select(collectionChange => new IndividualCollectionChange(collectionChange, jsCsBridgeCache, targetedType))
                         .OrderBy(idc => idc, this).ToArray();
 }
 public JavascriptListenerCSharpUpdater(ICSharpChangesListener cSharpChangesListener, IJsUpdateHelper jsUpdateHelper, IJavascriptToGlueMapper javascriptToGlueMapper)
 {
     _CSharpChangesListener  = cSharpChangesListener;
     _JsUpdateHelper         = jsUpdateHelper;
     _JavascriptToGlueMapper = javascriptToGlueMapper;
 }
Пример #22
0
 internal JsCommandWithoutParameter(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommandWithoutParameter command) :
     base(context, converter)
 {
     _Command    = command;
     _CanExecute = _Command.CanExecute;
 }
Пример #23
0
 public JsMappedCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommand <T> resultCommand)
     : base(context, converter, resultCommand)
 {
 }