protected virtual void RegisterViewModels(IContainerBuilder builder, ViewModelToViewMap viewModelToViewMap)
 {
     foreach (var(viewModelType, _) in viewModelToViewMap)
     {
         builder.PerDependency(viewModelType, IfRegistered.Keep);
     }
 }
Ejemplo n.º 2
0
 public StoryboardViewLocator(
     ILogManager logManager,
     IViewControllerProvider viewControllerProvider,
     ViewModelToViewMap viewModelToViewMap)
 {
     _viewControllerProvider = viewControllerProvider;
     _logger             = logManager.GetLogger <StoryboardViewLocator>();
     _viewModelToViewMap = viewModelToViewMap;
 }
        public virtual ViewModelToViewMap GetViewModelToViewMapping(IEnumerable <Assembly> assemblies)
        {
            var viewModelToViewMap = new ViewModelToViewMap();

            foreach (var viewType in assemblies.SelectMany(SelectViewsTypes))
            {
                var viewModelType = viewType.BaseType.GetGenericArguments()[0];

                if (!viewModelType.IsAbstract)
                {
                    viewModelToViewMap.Add(viewModelType, viewType);
                }
            }

            return(viewModelToViewMap);
        }
Ejemplo n.º 4
0
        public void NavigateTo(BaseVM viewModel, Func <BaseVM, bool> afterViewClosed = null)
        {
            if (afterViewClosed != null)
            {
                viewModel.AfterViewClosed = afterViewClosed;
            }

            if (ViewModelToViewMap.TryGetValue(viewModel.GetType(), out Type viewType))
            {
                var view = Activator.CreateInstance(viewType) as BaseView;
                view.ViewModel = viewModel;

                views.Push(view);

                if (Region != null)
                {
                    Region.Content     = view;
                    Region.DataContext = viewModel;
                }
            }
        }
Ejemplo n.º 5
0
 public DroidViewLocator(ViewModelToViewMap viewModelToViewMap)
 {
     _viewModelToViewMap = viewModelToViewMap;
 }