protected virtual Page CreatePage(object viewModel) { var viewModelType = viewModel.GetType(); var pageTypeName = viewModel is RootFrameNavigationViewModelBase ? BuildRootFrameNavigationPageTypeName(viewModelType.FullName) : BuildPageTypeName(viewModelType.FullName); var pageType = Type.GetType(pageTypeName) ?? AssemblySource.FindTypeByNames(new[] { pageTypeName }); return((Page)Activator.CreateInstance(pageType)); }
// TODO YP: export to base, looks the same as Android impl. protected virtual Type GetTargetViewType(Type viewModelType) { if (_viewModelToViewMap.TryGetValue(viewModelType, out var targetViewType)) { return(targetViewType); } var targetTypeName = BuildViewTypeName(viewModelType); targetViewType = Type.GetType(targetTypeName) ! ?? AssemblySource.FindTypeByNames(new[] { targetTypeName }) !; if (targetViewType == null) { throw new InvalidOperationException($"Can't find target view type: {targetTypeName}"); } return(targetViewType); }