Пример #1
0
        public IMvxViewModel ReloadViewModel <TParameter>(IMvxViewModel <TParameter> viewModel, TParameter param, MvxViewModelRequest request, IMvxBundle?savedState, IMvxNavigateEventArgs?navigationArgs = null)
            where TParameter : notnull
        {
            var viewModelLocator = FindViewModelLocator(request);

            var parameterValues = new MvxBundle(request.ParameterValues);

            try
            {
                return(viewModelLocator.Reload(viewModel, param, parameterValues, savedState, navigationArgs));
            }
            catch (Exception exception)
            {
                throw exception.MvxWrap(
                          $"Failed to construct and initialize ViewModel for type {request.ViewModelType} from locator {viewModelLocator.GetType().Name} - check InnerException for more information");
            }
        }
        public ValueTask <IMvxViewModel> ReloadViewModel <TParameter>(IMvxViewModel <TParameter> viewModel, TParameter param, MvxViewModelRequest request, IMvxBundle?savedState, IMvxNavigateEventArgs?navigationArgs)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var viewModelLocator = FindViewModelLocator(request);

            var parameterValues = new MvxBundle(request.ParameterValues);

            try
            {
                viewModel = viewModelLocator.Reload(viewModel, param, parameterValues, savedState, navigationArgs);
            }
            catch (Exception exception)
            {
                throw exception.MvxWrap(
                          "Failed to reload a previously created created ViewModel for type {0} from locator {1} - check InnerException for more information",
                          request.ViewModelType !, viewModelLocator.GetType().Name);
            }

            return(new ValueTask <IMvxViewModel>(viewModel));
        }
Пример #3
0
 public IMvxViewModelLocator FindViewModelLocator(MvxViewModelRequest request)
 {
     return(DefaultLocator);
 }
Пример #4
0
        public IMvxViewModel ReloadViewModel <TParameter>(IMvxViewModel <TParameter> viewModel, TParameter param, MvxViewModelRequest request, IMvxBundle savedState, IMvxNavigateEventArgs navigationArgs)
            where TParameter : notnull
        {
            var viewModelLocator = FindViewModelLocator(request);

            var parameterValues = new MvxBundle(request.ParameterValues);

            try
            {
                viewModel = viewModelLocator.Reload(viewModel, param, parameterValues, savedState, navigationArgs);
            }
            catch (Exception exception)
            {
                throw exception.MvxWrap(
                          "Failed to reload a previously created created ViewModel for type {0} from locator {1} - check InnerException for more information",
                          request.ViewModelType, viewModelLocator.GetType().Name);
            }

            return(viewModel);
        }