当前位置: 首页>>代码示例>>C#>>正文


C# IMvxViewModel.GetType方法代码示例

本文整理汇总了C#中IMvxViewModel.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IMvxViewModel.GetType方法的具体用法?C# IMvxViewModel.GetType怎么用?C# IMvxViewModel.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMvxViewModel的用法示例。


在下文中一共展示了IMvxViewModel.GetType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Close

 public override sealed void Close(IMvxViewModel viewModel)
 {
     if (_fragmentHostRegistrationSettings.IsTypeRegisteredAsFragment(viewModel.GetType()))
         CloseFragment(viewModel);
     else
         CloseActivity(viewModel);
 }
开发者ID:cyrilcathala,项目名称:MvvmCross-AndroidSupport,代码行数:7,代码来源:MvxFragmentsPresenter.cs

示例2: Bind

        public void Bind(IMvxViewModel viewModel, IMvxBundle parameterValues = null, IMvxBundle savedState = null)
        {
            var controllerAware = viewModel as IControllerAware;
            if (controllerAware != null)
            {
                var viewModelType = viewModel.GetType();
                var name = viewModelType.FullName.Replace("ViewModel", "Controller");

                Type controllerType = GetControllerTypeForViewModel(_getCreateableTypes(), viewModel);

                if (controllerType == null)
                {
                    throw new ArgumentException(string.Format("Controller for view model {0} cannot be found.", viewModelType));
                }

                try
                {
                    var controller = (IMvxController) Mvx.IocConstruct(controllerType);
                    controllerAware.AttachController(controller);

                    var viewModelAware = controller as IViewModelAware;
                    if (viewModelAware != null)
                    {
                        viewModelAware.AttachViewModel(viewModel);
                    }

                    try
                    {
                        CallControllerInitMethods(controller, parameterValues);
                        if (savedState != null)
                        {
                            CallReloadStateMethods(controller, savedState);
                        }

                    }
                    catch (Exception ex)
                    {
                        MvxTrace.Error("MvxControllers: Problem initialising controller of type {0} - problem {1}",
                            controllerType.Name, ex.ToLongString());

                        throw;
                    }

                    controller.WaitForInitialize();
                }
                catch (Exception ex)
                {
                    MvxTrace.Error("MvxControllers: Problem creating controller of type {0} - problem {1}",
                        controllerType,
                        ex.ToLongString());

                    throw;
                }
            }
        }
开发者ID:woellij,项目名称:mvvmcross-controllers,代码行数:55,代码来源:ViewModelBinder.cs

示例3: RequestClose

        public void RequestClose(IMvxViewModel viewModel)
        {
            var topPage = _frame.Content;
            var view = topPage as IMvxView;

            if (view == null)
            {
                MvxTrace.Trace("request close ignored for {0} - no current view", viewModel.GetType().Name);
                return;
            }

            if (view.ViewModel != viewModel)
            {
                MvxTrace.Trace("request close ignored for {0} - current view is registered for a different viewmodel of type {1}", viewModel.GetType().Name, view.ViewModel.GetType().Name);
                return;
            }

            MvxTrace.Trace("request close for {0} - will close current page {1}", viewModel.GetType().Name, view.GetType().Name);
            _frame.GoBack();
        }
开发者ID:ChebMami38,项目名称:MvvmCross-Tutorials,代码行数:20,代码来源:ViewModelCloser.cs

示例4: Close

 public virtual bool Close(IMvxViewModel viewModel)
 {
     //Workaround for closing fragments. This will not work when showing multiple fragments of the same viewmodel type in one activity
     var frag = GetCurrentCacheableFragmentsInfo ().FirstOrDefault (x => x.ViewModelType == viewModel.GetType());
     if (frag == null)
     {
         return false;
     }
     // Close method can not be fully fixed at this moment. That requires some changes in main MvvmCross library
     CloseFragment(frag.Tag, frag.ContentId);
     return true;
 }
开发者ID:maxgrig,项目名称:MvvmCross-AndroidSupport,代码行数:12,代码来源:MvxCachingFragmentActivity.cs

示例5: RequestClose

        public void RequestClose(IMvxViewModel viewModel)
        {
            var nav = MasterNavigationController;
            var top = nav.TopViewController;
            var view = top as IMvxTouchView;

            if (view == null)
            {
                MvxTrace.Trace("request close ignored for {0} - no current view controller", viewModel.GetType().Name);
                return;
            }

            if (view.ViewModel != viewModel)
            {
                MvxTrace.Trace("request close ignored for {0} - current view controller is registered for a different viewmodel of type {1}", viewModel.GetType().Name, view.ViewModel.GetType().Name);
                return;
            }

            MvxTrace.Trace("request close for {0} - will close current view controller {1}", viewModel.GetType().Name, view.GetType().Name);
            nav.PopViewControllerAnimated(true);
        }
开发者ID:ChebMami38,项目名称:MvvmCross-Tutorials,代码行数:21,代码来源:CustomerManagementPresenter.cs

示例6: RequestClose

        public void RequestClose(IMvxViewModel viewModel)
        {
            var topActivity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>();
            
            var activity = topActivity.Activity;
            var view = activity as IMvxAndroidView;

            if (view == null)
            {
                MvxTrace.Trace("request close ignored for {0} - no current activity", viewModel.GetType().Name);
                return;
            }
            
            if (view.ViewModel != viewModel)
            {
                MvxTrace.Trace("request close ignored for {0} - current activity is registered for a different viewmodel of type {1}", viewModel.GetType().Name, view.ViewModel.GetType().Name);
                return;
            }

            MvxTrace.Trace("request close for {0} - will close current activity {1}", viewModel.GetType().Name, view.GetType().Name);
            activity.Finish();
        }
开发者ID:darkice-matt-crombie,项目名称:MvxSpinnerTest,代码行数:22,代码来源:SimpleDroidViewModelCloser.cs

示例7: CreateView

        public virtual IMvxTouchView CreateView(IMvxViewModel viewModel)
        {
            var viewModelType = viewModel.GetType();
            var request = MvxShowViewModelRequest.GetDefaultRequest(viewModelType);
            var view = CreateView(request);
            var viewModelProperty = view.GetType().GetProperty("ViewModel");
            if (viewModelProperty == null)
                throw new MvxException("ViewModel Property missing for " + view.GetType());

            if (!viewModelProperty.CanWrite)
                throw new MvxException("ViewModel Property readonly for " + view.GetType());

            viewModelProperty.SetValue(view, viewModel, null);
            return view;
        }
开发者ID:JoanMiro,项目名称:MvxMod,代码行数:15,代码来源:MvxTouchViewsContainer.cs

示例8: RunViewModelLifecycle

 protected void RunViewModelLifecycle(IMvxViewModel viewModel, IMvxBundle parameterValues, IMvxBundle savedState)
 {
     try
     {
         CallCustomInitMethods(viewModel, parameterValues);
         if (savedState != null)
         {
             CallReloadStateMethods(viewModel, savedState);
         }
         viewModel.Start();
     }
     catch (Exception exception)
     {
         throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name);
     }
 }
开发者ID:talisqualis,项目名称:MvvmCross-Build,代码行数:16,代码来源:MvxDefaultViewModelLocator.cs

示例9: GetControllerTypeForViewModel

        protected virtual Type GetControllerTypeForViewModel(IEnumerable<Type> createableTypes, IMvxViewModel viewModel)
        {
            var name = viewModel.GetType().FullName.Replace("ViewModel", "Controller");

            var controllerType = createableTypes.FirstOrDefault(t => t.FullName == name);

            if (controllerType == null)
            {
                throw new ArgumentException(string.Format("Controller type {0} cannot be found.", name));
            }

            return controllerType;
        }
开发者ID:woellij,项目名称:mvvmcross-controllers,代码行数:13,代码来源:ViewModelBinder.cs

示例10: GetControl

 public IMvxControl GetControl(IMvxViewModel viewModelType)
 {
     return GetControl(viewModelType.GetType());
 }
开发者ID:rvuistin,项目名称:MvvmCross-ControlsNavigation,代码行数:4,代码来源:MvxControlsContainer.cs

示例11: MvxViewModelInstanceRequest

 public MvxViewModelInstanceRequest(IMvxViewModel viewModelInstance)
     : base(viewModelInstance.GetType(), null, null, MvxRequestedBy.Unknown)
 {
     _viewModelInstance = viewModelInstance;
 }
开发者ID:ylyking,项目名称:mvx-unity-ngui,代码行数:5,代码来源:MvxViewModelInstanceRequest.cs

示例12: RunViewModelLifecycle

 private static void RunViewModelLifecycle(IMvxViewModel viewModel, IMvxBundle savedState,
     MvxViewModelRequest request)
 {
     try
     {
         if (request != null)
         {
             var parameterValues = new MvxBundle(request.ParameterValues);
             viewModel.CallBundleMethods("Init", parameterValues);
         }
         if (savedState != null)
         {
             viewModel.CallBundleMethods("ReloadState", savedState);
         }
         viewModel.Start();
     }
     catch (Exception exception)
     {
         throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name);
     }
 }
开发者ID:cyrilcathala,项目名称:MvvmCross-AndroidSupport,代码行数:21,代码来源:MvxFragmentExtensions.cs

示例13: FragmentInfo

 public FragmentInfo(string title, string tag, Type fragmentType, IMvxViewModel viewModel, object parameterValuesObject = null)
     : this(title, tag, fragmentType, viewModel.GetType(), parameterValuesObject)
 {
     ViewModel = viewModel;
 }
开发者ID:thefex,项目名称:MvvmCross-AndroidSupport,代码行数:5,代码来源:MvxCachingFragmentStatePagerAdapter.cs

示例14: GetIntentWithKeyFor

        public virtual Tuple<Intent, int> GetIntentWithKeyFor(IMvxViewModel viewModel)
        {
            var request = MvxViewModelRequest.GetDefaultRequest(viewModel.GetType());
            var intent = this.GetIntentFor(request);

            var key = Mvx.Resolve<IMvxChildViewModelCache>().Cache(viewModel);
            intent.PutExtra(SubViewModelKey, key);

            return new Tuple<Intent, int>(intent, key);
        }
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:10,代码来源:MvxAndroidViewsContainer.cs


注:本文中的IMvxViewModel.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。