Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        // 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);
        }