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(); }
internal JsCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommand command) : base(context, converter) { _Command = command; try { _CanExecute = _Command.CanExecute(null); } catch { } }
private static object GetArgument(this IJavascriptToGlueMapper converter, IJavascriptObject javascriptObject, Type targetType) { try { return(converter.GetGlueConvertible(javascriptObject, targetType).Source); } catch (Exception) { return(null); } }
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>()); } }
public JsSimpleCommandBase(HtmlViewContext context, IJavascriptToGlueMapper converter) { _HtmlViewContext = context; JavascriptToGlueMapper = converter; }
public JsResultCommand(HtmlViewContext context, ICSharpUnrootedObjectManager manager, IJavascriptToGlueMapper converter, IResultCommand <TResult> resultCommand) : base(context, manager, converter) { _JsResultCommand = resultCommand; }
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) { }
protected internal JsCommandBase(HtmlViewContext context, IJavascriptToGlueMapper converter) { JavascriptToGlueMapper = converter; _HtmlViewContext = context; }
public GlueMappingFactory(HtmlViewContext context, ICSharpToJsCache cacher, IJavascriptToGlueMapper converter, ObjectChangesListener onListener) : base(cacher, onListener) { _HtmlViewContext = context; _JavascriptToGlueMapper = converter; }
public JsMappableCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommand command) : base(context, converter, command) { }
internal JsCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommand <T> command) : base(context, converter) { _Command = command; _CanExecute = true; }
internal IndividualCollectionChange(IndividualJavascriptCollectionChange change, IJavascriptToGlueMapper mapper, Type targetType) { CollectionChangeType = change.CollectionChangeType; Index = change.Index; Mapable = mapper.GetGlueConvertible(change.Object, targetType); }
public CollectionChanges.CollectionChanges GetChanger(JavascriptCollectionChanges changes, IJavascriptToGlueMapper bridge) { return(new CollectionChanges.CollectionChanges(bridge, changes, _IndividualType)); }
public JsMappableResultCommand(HtmlViewContext context, ICSharpUnrootedObjectManager manager, IJavascriptToGlueMapper converter, IResultCommand <TArg, TResult> resultCommand) : base(context, manager, converter, resultCommand) { }
internal static object GetFirstArgumentOrNull(this IJavascriptToGlueMapper converter, IJavascriptObject[] javascriptObjects) { return(javascriptObjects.Length == 0 ? null : converter.GetArgument(javascriptObjects[0], null)); }
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; }
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; }
internal JsCommandWithoutParameter(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommandWithoutParameter command) : base(context, converter) { _Command = command; _CanExecute = _Command.CanExecute; }
public JsMappedCommand(HtmlViewContext context, IJavascriptToGlueMapper converter, ICommand <T> resultCommand) : base(context, converter, resultCommand) { }