• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ViewModels.MvxViewModelRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Cirrious.MvvmCross.ViewModels.MvxViewModelRequest的典型用法代码示例。如果您正苦于以下问题:C# MvxViewModelRequest类的具体用法?C# MvxViewModelRequest怎么用?C# MvxViewModelRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MvxViewModelRequest类属于Cirrious.MvvmCross.ViewModels命名空间,在下文中一共展示了MvxViewModelRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PrepareFragment

		protected void PrepareFragment (IMvxFragmentView fragment, MvxViewModelRequest request)
		{
			var loaderService = Mvx.Resolve<IMvxViewModelLoader> ();
			var viewModel = loaderService.LoadViewModel (request, null);

			fragment.ViewModel = viewModel;
		}
开发者ID:fatelord,项目名称:chgk,代码行数:7,代码来源:ChGKPresenter.cs


示例2: CreateViewOfType

 protected override IMvxTouchView CreateViewOfType(Type viewType, MvxViewModelRequest request)
 {
     var storyboardName = UserInterfaceIsPhone ? "iPhone" : "iPad";
     var storyboard = UIStoryboard.FromName(storyboardName, null);
     return (IMvxTouchView)storyboard
         .InstantiateViewController(viewType.Name);
 }
开发者ID:SaberZA,项目名称:KcMvvm,代码行数:7,代码来源:KcContainer.cs


示例3: Show

 public override sealed void Show(MvxViewModelRequest request)
 {
     if (_fragmentHostRegistrationSettings.IsTypeRegisteredAsFragment(request.ViewModelType))
         ShowFragment(request);
     else
         ShowActivity(request);
 }
开发者ID:cyrilcathala,项目名称:MvvmCross-AndroidSupport,代码行数:7,代码来源:MvxFragmentsPresenter.cs


示例4: Handle

        public static bool Handle(string path)
        {
            var viewDispatcher = Mvx.Resolve<Cirrious.MvvmCross.Views.IMvxViewDispatcher>();
            var appService = Mvx.Resolve<IApplicationService>();
            if (!path.EndsWith("/", StringComparison.Ordinal))
                path += "/";

            foreach (var route in Routes)
            {
                var regex = new Regex(route.Path, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
                var match = regex.Match(path);
                var groups = regex.GetGroupNames().Skip(1);

                if (match.Success)
                {
                    var rec = new MvxViewModelRequest();
                    rec.ViewModelType = route.ViewModelType;
                    rec.ParameterValues = new Dictionary<string, string>();
                    foreach (var group in groups)
                        rec.ParameterValues.Add(group, match.Groups[group].Value);
                    appService.SetUserActivationAction(() => viewDispatcher.ShowViewModel(rec));
                    return true;
                }
            }

            return false;
        }
开发者ID:royalwang,项目名称:CodeHub,代码行数:27,代码来源:UrlRouterProvider.cs


示例5: Show

        public virtual async void Show(MvxViewModelRequest request)
        {
            if (await TryShowPage(request))
                return;

            Mvx.Error("Skipping request for {0}", request.ViewModelType.Name);
        }
开发者ID:sammyroller,项目名称:Cheesebaron.MvxPlugins,代码行数:7,代码来源:MvxFormsPagePresenter.cs


示例6: Show

 // thats an OVERLOAD!, just in case somebody reads way to fast ;)
 public void Show(MvxViewModelRequest request, bool viewModelShouldHandleError = true)
 {
     // TODO: use an as cast with an null check instead?
     if (ImplementsInterface(request.ViewModelType, typeof(IConditionalViewModel))) {
         // check condition here
         var loader = Mvx.Resolve<IMvxViewModelLoader>();
         var viewModel = loader.LoadViewModel(request, null) as IConditionalViewModel;
         if (viewModel.Precondition(viewModelShouldHandleError) == false) {
             if (viewModelShouldHandleError) {
                 // in this case the ViewModel already handled the error - if it did nothing ( no redirect ) basically just nothing happens
                 return;
             }
             else {
                 // The calle asked us ot inform him if the viewmodel does not allow instantiation to handle the error himself, so throw an Exception
                 throw new ViewNotAllowedException();
             }
         }
         else {
             var view = this.CreateViewControllerFor(request);
             // reuse the viewModel
             view.ViewModel = viewModel;
             Show(view);
         }
     }
     else {
         // no conditions, classiv way
         var view = this.CreateViewControllerFor(request);
         Show(view);
     }
 }
开发者ID:EugenMayer,项目名称:MvvmCrossConditions,代码行数:31,代码来源:ConditionalTouchPresenter.cs


示例7: Test_Round_Trip_Works_For_Normal_ViewModel_Requests

        public void Test_Round_Trip_Works_For_Normal_ViewModel_Requests()
        {
            ClearAll();

            var viewModelNameLookup = new MvxViewModelByNameLookup();
            viewModelNameLookup.AddAll(GetType().Assembly);
            Mvx.RegisterSingleton<IMvxViewModelByNameLookup>(viewModelNameLookup);

            var parameterBundle = new MvxBundle(new Dictionary<string, string> { { "On'e", "1'\\" }, { "Two", "2" } });
            var presentationBundle =
                new MvxBundle(new Dictionary<string, string> { { "Thre\"\'\\e", "3\"\'\\" }, { "Four", null } });
            var request = new MvxViewModelRequest<Test1ViewModel>(parameterBundle, presentationBundle,
                                                                  new MvxRequestedBy(
                                                                      MvxRequestedByType.AutomatedService, "HelloWorld"));

            var serializer = new MvxViewModelRequestCustomTextSerializer();
            var output = serializer.SerializeObject(request);

            var deserializer = new MvxViewModelRequestCustomTextSerializer();
            var deserialized = deserializer.DeserializeObject<MvxViewModelRequest>(output);

            Assert.AreEqual(typeof(Test1ViewModel), deserialized.ViewModelType);
            Assert.AreEqual(MvxRequestedByType.AutomatedService, deserialized.RequestedBy.Type);
            Assert.AreEqual("HelloWorld", deserialized.RequestedBy.AdditionalInfo);
            Assert.AreEqual(2, deserialized.PresentationValues.Count);
            Assert.AreEqual(2, deserialized.ParameterValues.Count);
            Assert.AreEqual("1'\\", deserialized.ParameterValues["On'e"]);
            Assert.AreEqual("2", deserialized.ParameterValues["Two"]);
            Assert.AreEqual("3\"\'\\", deserialized.PresentationValues["Thre\"\'\\e"]);
            Assert.AreEqual(null, deserialized.PresentationValues["Four"]);
        }
开发者ID:talisqualis,项目名称:MvvmCross-Build,代码行数:31,代码来源:MvxStringDictionaryTextSerializerTest.cs


示例8: Show

        public override void Show(MvxViewModelRequest request)
        {
            // XFViewModel means we need a Forms View
            if (request.ViewModelType.FullName.Contains ("XFViewModel"))
            {
                //get the xamarin.forms page from the ViewModel
                var contentPage = MvxPresenterHelpers.CreatePage (request);

                //MvvmCross call to create the view model with DI etc
                var viewModel = MvxPresenterHelpers.LoadViewModel (request);

                //Assign it to the Forms Binding Content
                contentPage.BindingContext = viewModel;

                //Creating the view controller from the content page
                var viewController = contentPage.CreateViewController ();

                if (this.MasterNavigationController == null)
                {
                    // If it's the first view
                    this.ShowFirstView (viewController);
                }
                else
                {
                    // If it's already in the stack
                    this.MasterNavigationController.PushViewController (viewController, true);
                }

            }
            else
            {
                //Using a normal MvvmCross View
                base.Show (request);
            }
        }
开发者ID:RasmusTG,项目名称:MvvmCrossNavigationDemo,代码行数:35,代码来源:MvxFormsTouchPagePresenter.cs


示例9: TryShowPage

        private async Task<bool> TryShowPage(MvxViewModelRequest request)
        {
            var page = MvxPresenterHelpers.CreatePage(request);
            if (page == null)
                return false;

            var viewModel = MvxPresenterHelpers.LoadViewModel(request);

            var mainPage = _mvxFormsApp.MainPage as NavigationPage;
            page.BindingContext = viewModel;

            if (mainPage == null)
            {
                _mvxFormsApp.MainPage = new NavigationPage(page);
                mainPage = _mvxFormsApp.MainPage as NavigationPage;
                CustomPlatformInitialization(mainPage);
            }
            else
            {
                try
                {
                    await mainPage.PushAsync(page);
                }
                catch (Exception e)
                {
                    Mvx.Error("Exception pushing {0}: {1}\n{2}", page.GetType(), e.Message, e.StackTrace);
                }
            }

            return true;
        }
开发者ID:sammyroller,项目名称:Cheesebaron.MvxPlugins,代码行数:31,代码来源:MvxFormsPagePresenter.cs


示例10: CreateViewOfType

		protected  override IMvxTouchView CreateViewOfType(Type viewType, MvxViewModelRequest request)
		{
			// If View is "SampleViewController", then Storyboard should be "SampleViewController.storyboard"
			// If we can't find storyboard, then proceed to load XIB..
			//
			// NOTE: You must have this ctor defined for Storyboard: 
			//
			//   public YourViewController (IntPtr handle) : base (handle)
			//
            // As indicated here: http://developer.xamarin.com/guides/ios/user_interface/introduction_to_storyboards/
            //

		    IMvxTouchView viewController = null;

			if (NSBundle.MainBundle.PathForResource (viewType.Name, "storyboardc") != null) {
				// If storyboard exists for this view, load it.
				System.Console.WriteLine ("Creating view from Storyboard {0}.storyboard", viewType.Name);
				var storyboard = UIStoryboard.FromName(viewType.Name, null);
				viewController = (IMvxTouchView)storyboard.InstantiateInitialViewController();
			}
			else {
				System.Console.WriteLine ("Storyboard {0}.storyboard does not exist: creating view of type instead", viewType.Name);
				viewController = (IMvxTouchView)base.CreateViewOfType(viewType, request);
			}

			if(viewController == null) {
				System.Console.WriteLine ("Can't create view for type:" + viewType.Name);
				throw new Exception ("Can't create view for type:" + viewType.Name);
			}									
			return viewController;
		}
开发者ID:kashifshaikh,项目名称:PropertyTracker,代码行数:31,代码来源:AppContainer.cs


示例11: Test_NormalViewModel

        public void Test_NormalViewModel()
        {
            ClearAll();

            IMvxViewModel outViewModel = new Test2ViewModel();

            var mockLocator = new Mock<IMvxViewModelLocator>();
            mockLocator.Setup(
                m => m.Load(It.IsAny<Type>(), It.IsAny<IMvxBundle>(), It.IsAny<IMvxBundle>()))
                       .Returns(() => outViewModel);

            var mockCollection = new Moq.Mock<IMvxViewModelLocatorCollection>();
            mockCollection.Setup(m => m.FindViewModelLocator(It.IsAny<MvxViewModelRequest>()))
                          .Returns(() => mockLocator.Object);

            Ioc.RegisterSingleton(mockCollection.Object);

            var parameters = new Dictionary<string, string> { { "foo", "bar" } };
            var request = new MvxViewModelRequest<Test2ViewModel>(new MvxBundle(parameters), null,
                                                                  MvxRequestedBy.UserAction);
            var state = new MvxBundle();
            var loader = new MvxViewModelLoader();
            var viewModel = loader.LoadViewModel(request, state);

            Assert.AreSame(outViewModel, viewModel);
            Assert.AreEqual(MvxRequestedBy.UserAction, viewModel.RequestedBy);
        }
开发者ID:talisqualis,项目名称:MvvmCross-Build,代码行数:27,代码来源:MvxViewModelLoaderTest.cs


示例12: Show

		public override void Show(MvxViewModelRequest request)
		{
            if (TryShowPage(request))
				return;

			Mvx.Error("Skipping request for {0}", request.ViewModelType.Name);
		}
开发者ID:JacobAtchley,项目名称:MyVote,代码行数:7,代码来源:MvxPagePresenter.cs


示例13: CreateView

        public virtual IMvxUnityView CreateView(MvxViewModelRequest request)
        {
            try
            {
                CurrentRequest = request;

                IMvxUnityView view;
                //var viewType = GetViewType(request.ViewModelType);
                //if (viewType == null)
                //    throw new MvxException("View Type not found for " + request.ViewModelType);

                var customAttribute = (MvxViewAttribute)request.ViewModelType.GetCustomAttributes(typeof(MvxViewAttribute), false).FirstOrDefault();

                if (customAttribute != null)
                {
                    string viewUrl = customAttribute.Url;

                    GameObject prefab = (GameObject)UnityEngine.Resources.Load(viewUrl);

                    Camera uiCamera = NGUITools.FindCameraForLayer(prefab.layer);

                    Vector3 newPosition;
                    if (prefab.layer == LayerMask.NameToLayer("UI"))
                    {
                        newPosition = new Vector3(0, 0, uiCamera.farClipPlane + 100f);
                    }
                    else
                    {
                        newPosition = Vector3.zero;
                    }

                    GameObject go = GameObject.Instantiate(prefab, newPosition, Quaternion.identity) as GameObject;

                    PreventCameraSwapOnUIAnchor(go);

                    view = go.GetComponent(typeof(IMvxUnityView)) as IMvxUnityView;
                }
                else
                {
                    /*
                    GameObject go = new GameObject();
                    go.name = request.ViewModelType.Name + "(Clone)";
                    go = go.AddComponent(viewType).gameObject;
                    view = go.GetComponent(typeof(IMvxUnityView)) as IMvxUnityView;
                    */
                    throw new Exception("Unable to find MvxViewAttribute on ViewModel: " + request.ViewModelType.Name);
                }

                if (view == null)
                    throw new MvxException("View not loaded for " + request.ViewModelType);

                view.Request = request;
                return view;
            }
            finally
            {
                CurrentRequest = null;
            }
        }
开发者ID:JordanMarr,项目名称:mvx-unity-ngui,代码行数:59,代码来源:MvxUnityGenericViewsContainer.cs


示例14: ShowViewModel

 // thats an OVERLOAD!, just in case somebody reads way to fast ;)
 public bool ShowViewModel(MvxViewModelRequest request, bool viewModelShouldHandleError = true)
 {
     Action action = () => {
         MvxTrace.TaggedTrace("TouchNavigation", "Navigate requested");
         _presenter.Show(request);
     };
     return RequestMainThreadAction(action);
 }
开发者ID:EugenMayer,项目名称:MvvmCrossConditions,代码行数:9,代码来源:ConditionalTouchDispatcher.cs


示例15: CreateViewOfType

 protected override IMvxTouchView CreateViewOfType(Type viewType, MvxViewModelRequest request)
 {
     // Get storyboard using the View name that is passed. This will only work if the Storyboard ID is set on the .storyboard file
     // If we move to unified storyboards this will not be necessary
     var sb = UIStoryboard.FromName(string.Format("{0}_{1}", viewType.Name, UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone ? "iPhone" : "iPad"), NSBundle.MainBundle);
     var vc = sb.InstantiateViewController(viewType.Name);
     return vc as IMvxTouchView;
 }
开发者ID:drewdz,项目名称:BarcodeScanner,代码行数:8,代码来源:TouchViewsContainer.cs


示例16: CreateViewOfType

        protected override IMvxTouchView CreateViewOfType(Type viewType, MvxViewModelRequest request)
        {
            MvxTrace.Trace(MvxTraceLevel.Diagnostic, "Create iOS View:" + viewType.Name);
            var storyboard = UIStoryboard.FromName("Main", null);
            var returnValue = storyboard.InstantiateViewController(viewType.Name);

            return (IMvxTouchView)returnValue;
        }
开发者ID:Magenic,项目名称:WhitepaperPerformance,代码行数:8,代码来源:TouchViewsContainer.cs


示例17: Show

        protected virtual void Show(IMvxMacView view, MvxViewModelRequest request)
        {
            var viewController = view as NSViewController;
            if (viewController == null)
                throw new MvxException("Passed in IMvxTouchView is not a UIViewController");

            Show(viewController, request);
        }
开发者ID:talisqualis,项目名称:MvvmCross-Build,代码行数:8,代码来源:MvxMacViewPresenter.cs


示例18: Show

		public override void Show (MvxViewModelRequest request)
		{
			if (_customPresenterOpenScenarios.ContainsKey (request.ViewModelType)) {
				_customPresenterOpenScenarios [request.ViewModelType] (request);
			} else {
				base.Show (request);
			}
		}
开发者ID:fatelord,项目名称:chgk,代码行数:8,代码来源:ChGKPresenter.cs


示例19: Show

        public bool Show(MvxViewModelRequest request, Bundle bundle)
        {
            drawerLayout.CloseDrawers();

            int targetId = request.ViewModelType == typeof(MenuViewModel) ? Resource.Id.left_drawer : Resource.Id.content_frame;
            ShowFragment(request.ViewModelType.Name, targetId, bundle);

            return true;
        }
开发者ID:CecileRobertMichon,项目名称:Xam.NavDrawer,代码行数:9,代码来源:HomeActivity.cs


示例20: ShowViewModel

 public bool ShowViewModel(MvxViewModelRequest request)
 {
     Action action = () =>
     {
         MvxTrace.TaggedTrace("UnityNavigation", "Navigate requested");
         _presenter.Show(request);
     };
     return RequestMainThreadAction(action);
 }
开发者ID:JordanMarr,项目名称:mvx-unity-ngui,代码行数:9,代码来源:MvxUnityViewDispatcher.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ClangSharp.CXCursor类代码示例发布时间:2022-05-24
下一篇:
C# Platform.MvxApplicationDelegate类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap