private void Start() { Transform canvas = this.transform; _viewFactory = new ViewFactory(); _viewFactory.Create <TestView_01, TestViewModel>(canvas, (view, viewmodel) => { _viewDic[ViewType.Test_01] = view; _viewModelDic[ViewType.Test_01] = viewmodel; }); IView view2 = new TestView_02(); IViewModel viewmodel2 = new TestViewModel() { Text = "界面二" }; _viewFactory.Create(view2, viewmodel2, canvas, () => { _viewDic[ViewType.Test_02] = view2; _viewModelDic[ViewType.Test_02] = viewmodel2; }); }
public void ImportConfig() { IImportFileView importView = (IImportFileView)_viewFactory.Create("ImportView"); if (importView.ShowDialog() == DialogResult.OK) { UpdateView(); } }
private void ShowMainWindow(ICurrentUserViewModel currentUser) { var mainViewModel = mainViewModelFactory.Create(currentUser); var mainView = viewFactory.Create <IMainWindow>(); mainView.DataContext = mainViewModel; mainView.ShowDialog(); }
public override void Execute(object parameter) { IEditTaskViewModel editTaskViewModel = editTaskViewModelFactory.Create(SelectedItem.Id); IEditTaskView editTaskView = editTaskViewFactory.Create(editTaskViewModel); editTaskView.ShowDialog(); }
public View OnCreateView(string name, Context context, IAttributeSet attrs) { if (name == "fragment") { return(null); } ViewResult viewResult = _viewFactory.Create(name, context, attrs); View view = viewResult.View; IList <string> bindings = viewResult.DataContext.GetData(ViewFactoryConstants.Bindings); if (bindings != null) { var manualBindings = view as IManualBindings; if (manualBindings == null) { foreach (string binding in bindings) { SetBinding(view, binding); } } else { _bindings.AddRange(manualBindings.SetBindings(bindings)); } } return(view); }
private void CreateView(Vector3 position, ITileModel model, EnvironmentType type) { switch (type) { case EnvironmentType.Sea: _seaFactory.Create(position, model); break; case EnvironmentType.Grassland: _grassFactory.Create(position, model); break; case EnvironmentType.Swamp: _swampFactory.Create(position, model); break; case EnvironmentType.Desert: _desertFactory.Create(position, model); break; case EnvironmentType.Mountain: _mountainFactory.Create(position, model); break; default: throw new ArgumentOutOfRangeException(); } }
public override void Initialize() { _model.Consequence .Where(type => type == ConsequenceType.PollenExplosion) .Subscribe(_ => _pollenFactory.Create(_gameObject.transform.position)) .AddTo(_disposer); }
public override void Initialize() { _model.Consequence .Where(type => type == ConsequenceType.Hurricane) .Subscribe(_ => _tornadoFactory.Create(_gameObject.transform.position)) .AddTo(_disposer); }
public TView Create() { return(Application.Current?.Dispatcher?.Invoke(() => { return viewFactory.Create <TView>(); })); }
void ExecuteEditTimeBlock() { IEditTimeBlockViewModel editTimeBlockViewModel = editTimeBlockViewModelFactory.Create(SelectedItem.Id); IEditTimeBlockView editTimeBlockView = editTimeBlockViewFactory.Create(editTimeBlockViewModel); editTimeBlockView.ShowDialog(); }
public override void Initialize() { _model.Consequence .Where(type => type == ConsequenceType.AnimalSwarm) .Subscribe(_ => _viewFactory.Create(_gameObject.transform.position)) .AddTo(_disposer); }
public T Get <T>() where T : View { if (!_viewContext.Views.ContainsKey(typeof(T))) { var view = _factory.Create <T>(); _viewContext.Views.Add(typeof(T), view); } return((T)_viewContext.Views[typeof(T)]); }
public T GetView <T>(ModuleOptions pModuleType) { if (mCatalog.ContainsKey(pModuleType)) { IViewFactory <T> factory = (IViewFactory <T>)mCatalog[pModuleType]; return(factory.Create()); } else { return(default(T)); } }
public IView GetViewForRequest(IWebServerRequest request) { string viewsDirectory = request.WebSite.GetOsFilePath("Views"); string masterPage = Directory.GetFiles(viewsDirectory, "Master.*").FirstOrDefault(); string sectionDirectory = Path.Combine(viewsDirectory, request.ViewTemplateSection); string sectionMasterPage = Directory.GetFiles(sectionDirectory, "Master.*").FirstOrDefault(); string viewTemplateFilter = string.Format("{0}.*", request.ViewTemplateName); string viewTemplatePage = Directory.GetFiles(sectionDirectory, viewTemplateFilter).FirstOrDefault(); //TODO - Caching return(viewFactory.Create(masterPage, sectionMasterPage, viewTemplatePage)); }
public async void NavigateTo(string path, object payload) { NoomRequest request = new NoomRequest(path, payload); NoomRouterEntry entry = router.Match(request); ISegment[] segments = GetSegments(request); IViewFactory factory = await entry.GetView(request); IView view = factory.Create(tools); await destination.Render(view, request); destination.Render(segments); }
/// <summary> /// create new view element /// </summary> /// <param name="viewModel">target element model data</param> /// <param name="viewType">view type filter</param> /// <param name="skinTag">target element skin</param> /// <param name="parent">view parent</param> /// <returns>created view element</returns> public async UniTask <IView> CreateView( IViewModel viewModel, Type viewType, string skinTag = "", Transform parent = null, string viewName = null, bool stayWorld = false) { var view = (await _viewFactory.Create(viewType, skinTag, parent, viewName, stayWorld)); await InitializeView(view, viewModel); return(view); }
public CacheableView GetView(string cell_id) { if (String.IsNullOrEmpty(cell_id)) { return(null); } if (!_viewCache.ContainsKey(cell_id) || _viewCache[cell_id].Count == 0) { var view = _factory.Create(cell_id); view.CellID = cell_id; view.ViewCache = this; return(view); } else { return(_viewCache[cell_id].Pop()); } }
ITicketDetailsView CreateView() { return(viewFactory.Create <ITicketDetailsView>()); }
protected virtual View OnCreateViewInternal(string name, Context context, IAttributeSet attrs) { View view = null; var fullName = GetFullName(name); if (PlatformExtensions.IsApiGreaterThan10 && NestedFactory2 != null) { if (fullName != null) { view = NestedFactory2.OnCreateView(fullName, context, attrs); } if (view == null) { view = NestedFactory2.OnCreateView(name, context, attrs); } } else if (NestedFactory != null) { if (fullName != null) { view = NestedFactory.OnCreateView(fullName, context, attrs); } if (view == null) { view = NestedFactory.OnCreateView(name, context, attrs); } } if (_ignoreViewTypes.Contains(name)) { return(view); } ViewResult viewResult; if (view == null) { viewResult = _viewFactory.Create(name, Context, attrs); view = viewResult.View; } else { var type = TypeCache <View> .Instance.GetTypeByName(name, true, false); if (type != null) { var clazz = Java.Lang.Class.FromType(type); if (clazz.IsInstance(view) && !type.IsInstanceOfType(view)) { view = (View)JavaCastMethod.MakeGenericMethod(type).InvokeEx(null, view); } } viewResult = _viewFactory.Initialize(view, attrs); } IList <string> bindings = viewResult.DataContext.GetData(ViewFactoryConstants.Bindings); if (bindings != null) { var manualBindings = view as IManualBindings; if (manualBindings == null) { foreach (string binding in bindings) { BindingServiceProvider .BindingProvider .CreateBindingsFromString(view, binding); } } else { manualBindings.SetBindings(bindings); } } Func <View, string, Context, IAttributeSet, View> viewCreated = PlatformExtensions.ViewCreated; if (viewCreated == null) { return(view); } return(viewCreated(view, name, Context, attrs)); }
ITicketDetailsView CreateView() { var view = viewFactory.Create <ITicketDetailsView>(); return(view); }
private View OnViewCreated(View view, string name, Context context, IAttributeSet attrs) { if (name == "fragment" || (view != null && _lastCreatedView.Target == view)) { return(view); } ViewResult viewResult; if (view == null) { var type = TypeCache <View> .Instance.GetTypeByName(name, true, false); if (type == null) { return(null); } viewResult = _viewFactory.Create(type, context, attrs); view = viewResult.View; } else { var type = TypeCache <View> .Instance.GetTypeByName(name, true, false); if (type != null && !type.IsInstanceOfType(view)) { try { view = (View)JavaCastMethod.MakeGenericMethod(type).Invoke(null, new object[] { view }); } catch { ; } } viewResult = _viewFactory.Initialize(view, attrs); } var viewCreated = PlatformExtensions.ViewCreated; if (viewCreated != null) { view = viewCreated(view, name, context, attrs); } if (!viewResult.IsEmpty) { view = viewResult.View; var bind = viewResult.Bind; if (!string.IsNullOrEmpty(bind)) { var manualBindings = view as IManualBindings; if (manualBindings == null) { BindingServiceProvider.BindingProvider.CreateBindingsFromString(view, bind); } else { manualBindings.SetBindings(bind); } } } var viewGroup = view as ViewGroup; if (viewGroup != null && !viewGroup.GetBindingMemberValue(AttachedMembers.ViewGroup.DisableHierarchyListener)) { viewGroup.SetOnHierarchyChangeListener(GlobalViewParentListener.Instance); } _lastCreatedView = ServiceProvider.WeakReferenceFactory(view); return(view); }
public override void Execute(object parameter) { INewGroupView newGroupView = newGroupViewFactory.Create(); newGroupView.ShowDialog(); }
private View OnViewCreated(View view, string name, Context context, IAttributeSet attrs) { if (name == "fragment" || view != null && _lastCreatedView.Target == view) { return(view); } ViewResult viewResult; if (view == null) { var type = TypeCache <View> .Instance.GetTypeByName(name, true, false); if (type == null) { return(null); } viewResult = _viewFactory.Create(type, context, attrs); view = viewResult.View; } else { var type = TypeCache <View> .Instance.GetTypeByName(name, true, false); if (type != null && !type.IsInstanceOfType(view)) { try { view = (View)JavaCastMethod.MakeGenericMethod(type).Invoke(null, new object[] { view }); } catch { ; } } viewResult = _viewFactory.Initialize(view, attrs); } var viewCreated = AndroidToolkitExtensions.ViewCreated; if (viewCreated != null) { view = viewCreated(view, name, context, attrs); } string bind = null; if (!viewResult.IsEmpty) { view = viewResult.View; bind = viewResult.Bind; if (!string.IsNullOrEmpty(bind)) { if (AndroidToolkitExtensions.CurrentLayoutInflaterResult == null) { var manualBindings = view as IManualBindings; if (manualBindings == null) { BindingServiceProvider.BindingProvider.CreateBindingsFromString(view, bind); } else { manualBindings.SetBindings(bind); } } } } if (AndroidToolkitExtensions.CurrentLayoutInflaterResult == null) { var viewGroup = view as ViewGroup; if (viewGroup != null && !viewGroup.IsDisableHierarchyListener()) { viewGroup.SetOnHierarchyChangeListener(GlobalViewParentListener.Instance); } } else { Action <object> postAction; if (view is ViewGroup) { postAction = o => { var vg = (ViewGroup)o; if (!vg.IsDisableHierarchyListener()) { vg.SetOnHierarchyChangeListener(GlobalViewParentListener.Instance); } }; } else { postAction = null; } AndroidToolkitExtensions.CurrentLayoutInflaterResult.AddBindingInfo(view, bind, postAction); } _lastCreatedView = ServiceProvider.WeakReferenceFactory(view); return(view); }
public void Execute() { IMainView mainView = mainViewFactory.Create(); mainView.Show(); }