protected void RefreshDefaultStyleSheet() { View.DefaultStyleSheet = Factory.DefaultStyleSheet; Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { CachedViews.Remove(Factory.GetType()); }), DispatcherPriority.Background); }
void CreateView(object source) { if (source == null) { View = null; } else { ICollectionViewFactory factory = source as ICollectionViewFactory; if (factory != null) { View = factory.CreateView(); if (View == null) { throw new InvalidOperationException(string.Format("ICollectionViewFactory.CreateView must not return null", source.GetType().Name)); } } else { ICollectionView view = null; if (CachedViews.TryGetValue(source, out view)) { View = view; } else { view = CollectionView.Create((IEnumerable)source); CachedViews.Add(source, view); View = view; } } } Refresh(); }
private static ReactViewRender CreateReactViewInstance(ReactViewFactory factory) { ReactViewRender InnerCreateView() { var view = new ReactViewRender(factory.DefaultStyleSheet, () => factory.InitializePlugins(), factory.EnableViewPreload, factory.EnableDebugMode, factory.DevServerURI); if (factory.ShowDeveloperTools) { view.ShowDeveloperTools(); } return(view); } if (factory.EnableViewPreload) { var factoryType = factory.GetType(); // check if we have a view cached for the current factory if (CachedViews.TryGetValue(factoryType, out var cachedView)) { CachedViews.Remove(factoryType); } // create a new view in the background and put it in the cache Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { if (!CachedViews.ContainsKey(factoryType) && !Dispatcher.CurrentDispatcher.HasShutdownStarted) { CachedViews.Add(factoryType, InnerCreateView()); } }), DispatcherPriority.Background); if (cachedView != null) { return(cachedView); } } return(InnerCreateView()); }
private static ReactViewRender CreateReactViewInstance(ReactViewFactory factory) { ReactViewRender InnerCreateView() { var view = new ReactViewRender(factory.DefaultStyleSheet, () => factory.InitializePlugins(), factory.EnableViewPreload, factory.MaxNativeMethodsParallelCalls, factory.EnableDebugMode, factory.DevServerURI, factory.RegisterWebJavaScriptObject, factory.UnregisterWebJavaScriptObject, factory.ExecuteWebScriptFunctionWithSerializedParams); if (factory.ShowDeveloperTools) { view.ShowDeveloperTools(); } return(view); } if (factory.EnableViewPreload) { var factoryType = factory.GetType(); // check if we have a view cached for the current factory if (CachedViews.TryGetValue(factoryType, out var cachedView)) { CachedViews.Remove(factoryType); } // create a new view in the background and put it in the cache AsyncExecuteInUI(() => { if (!CachedViews.ContainsKey(factoryType)) { CachedViews.Add(factoryType, InnerCreateView()); } }, lowPriority: true); if (cachedView != null) { return(cachedView); } } return(InnerCreateView()); }
protected void RefreshDefaultStyleSheet() { View.DefaultStyleSheet = Factory.DefaultStyleSheet; AsyncExecuteInUI(() => CachedViews.Remove(Factory.GetType()), lowPriority: true); }