Пример #1
0
 void InitViewType()
 {
     if (ViewType != null || string.IsNullOrEmpty(ViewName))
     {
         return;
     }
     ViewType = viewLocator.ResolveViewType(ViewName);
 }
Пример #2
0
        /// <summary>
        /// Gets the view type for the given view model.
        /// </summary>
        /// <typeparam name="TViewModel">The type of view model to get the view for.</typeparam>
        /// <exception cref="ViewNotFoundException">no view found of the given view model type.</exception>
        public static Type ResolveViewType <TViewModel>(this IViewLocator viewLocator)
            where TViewModel : class
        {
            if (viewLocator is null)
            {
                throw new ArgumentNullException(nameof(viewLocator));
            }

            return(viewLocator.ResolveViewType(typeof(TViewModel)));
        }
Пример #3
0
        public static DataTemplate CreateViewTemplate(this IViewLocator viewLocator, string viewName)
        {
            Verify(viewLocator);
            Type viewType = viewLocator.ResolveViewType(viewName);

            if (viewType == null)
            {
                return(CreateFallbackViewTemplate(GetErrorMessage_CannotResolveViewType(viewName)));
            }
            return(CreateViewTemplate(viewLocator, viewType));
        }
Пример #4
0
        private Type LocatePageFor(object viewModel, string contract)
        {
            var viewType = _viewLocator.ResolveViewType(viewModel, contract);

            if (viewType == null)
            {
                throw new InvalidOperationException($"No view could be located for type '{viewModel.GetType().FullName}', contract '{contract}'. Be sure Splat has an appropriate registration.");
            }

            return(viewType);
        }