Exemplo n.º 1
0
 public MvxViewModelRequest(Type viewModelType,
                            IMvxBundle parameterBundle,
                            IMvxBundle presentationBundle,
                            MvxRequestedBy requestedBy)
 {
     this.ViewModelType = viewModelType;
     this.ParameterValues = parameterBundle.SafeGetData();
     this.PresentationValues = presentationBundle.SafeGetData();
     this.RequestedBy = requestedBy;
 }
Exemplo n.º 2
0
 protected bool ShowViewModel <TViewModel>(object parameterValuesObject,
                                           IMvxBundle presentationBundle = null,
                                           MvxRequestedBy requestedBy    = null)
     where TViewModel : IMvxViewModel
 {
     return(this.ShowViewModel(
                typeof(TViewModel),
                parameterValuesObject.ToSimplePropertyDictionary(),
                presentationBundle,
                requestedBy));
 }
Exemplo n.º 3
0
 protected bool ShowViewModel <TViewModel>(IMvxBundle parameterBundle    = null,
                                           IMvxBundle presentationBundle = null,
                                           MvxRequestedBy requestedBy    = null)
     where TViewModel : IMvxViewModel
 {
     return(this.ShowViewModel(
                typeof(TViewModel),
                parameterBundle,
                presentationBundle,
                requestedBy));
 }
Exemplo n.º 4
0
 protected bool ShowViewModel <TViewModel>(IDictionary <string, string> parameterValues,
                                           IMvxBundle presentationBundle = null,
                                           MvxRequestedBy requestedBy    = null)
     where TViewModel : IMvxViewModel
 {
     return(this.ShowViewModel(
                typeof(TViewModel),
                new MvxBundle(parameterValues.ToSimplePropertyDictionary()),
                presentationBundle,
                requestedBy));
 }
 private static void ViewModelRequestForSegueImpl(this IMvxEventSourceViewController _, UIStoryboardSegue segue, IMvxBundle parameterBundle = null)
 {
     var view = segue.DestinationViewController as IMvxIosView;
     if (view != null && view.Request == null)
     {
         var type = view.GetViewModelType();
         if (type != null)
         {
             var by = new MvxRequestedBy(MvxRequestedByType.Other, $"Segue: {segue.Identifier}");
             view.Request = new MvxViewModelRequest(type, parameterBundle, null, by);
         }
     }
 }
Exemplo n.º 6
0
        private bool ShowViewModelImpl(Type viewModelType, IMvxBundle parameterBundle, IMvxBundle presentationBundle,
                                       MvxRequestedBy requestedBy)
        {
            MvxTrace.Trace("Showing ViewModel {0}", viewModelType.Name);
            var viewDispatcher = this.ViewDispatcher;

            if (viewDispatcher != null)
            {
                return(viewDispatcher.ShowViewModel(new MvxViewModelRequest(
                                                        viewModelType,
                                                        parameterBundle,
                                                        presentationBundle,
                                                        requestedBy)));
            }

            return(false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// ShowViewModel with non-primitive type object using json to pass object to the next ViewModel
        /// Be aware that pasing big objects will block your UI, and should be handled async by yourself
        /// </summary>
        /// <param name="parameter">The generic object you want to pass onto the next ViewModel</param>
        protected bool ShowViewModel <TViewModel, TInit>(TInit parameter,
                                                         IMvxBundle presentationBundle = null,
                                                         MvxRequestedBy requestedBy    = null)
            where TViewModel : IMvxViewModelInitializer <TInit>
        {
            IMvxJsonConverter serializer;

            if (!Mvx.TryResolve(out serializer))
            {
                throw new MvxIoCResolveException("There is no implementation of IMvxJsonConverter registered. You need to use the MvvmCross Json plugin or create your own implementation of IMvxJsonConverter.");
            }

            var json = serializer.SerializeObject(parameter);

            return(this.ShowViewModel <TViewModel>(new Dictionary <string, string> {
                { "parameter", json }
            }, presentationBundle, requestedBy));
        }
Exemplo n.º 8
0
        /// <summary>
        /// ShowViewModel with non-primitive type object using json to pass object to the next ViewModel
        /// Be aware that pasing big objects will block your UI, and should be handled async by yourself
        /// </summary>
        /// <param name="parameter">The generic object you want to pass onto the next ViewModel</param>
        protected bool ShowViewModel <TViewModel, TInit>(TInit parameter,
                                                         IMvxBundle presentationBundle = null,
                                                         MvxRequestedBy requestedBy    = null)
            where TViewModel : IMvxViewModelInitializer <TInit>
        {
            IMvxJsonConverter serializer;

            if (!Mvx.TryResolve(out serializer))
            {
                Mvx.Trace(
                    "Could not resolve IMvxJsonConverter, it is going to be hard to initialize with custom object");
                return(false);
            }

            var json = serializer.SerializeObject(parameter);

            return(this.ShowViewModel <TViewModel>(new Dictionary <string, string> {
                { "parameter", json }
            }, presentationBundle, requestedBy));
        }