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


C# Region.Add方法代码示例

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


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

示例1: WhenRegionHasMultipleViews_ThenViewsWithMatchingTypeNameAreConsidered

        public void WhenRegionHasMultipleViews_ThenViewsWithMatchingTypeNameAreConsidered()
        {
            // Arrange

            var serviceLocatorMock = new Mock<IServiceLocator>();

            var region = new Region();

            var view1 = new TestView();
            var view2 = "view";

            region.Add(view1);
            region.Add(view2);

            var navigationContext = new NavigationContext(null, new Uri(view2.GetType().Name, UriKind.Relative));

            var navigationTargetHandler = new TestRegionNavigationContentLoader(serviceLocatorMock.Object);


            // Act

            var returnedView = navigationTargetHandler.LoadContent(region, navigationContext);


            // Assert

            Assert.AreSame(view2, returnedView);
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:28,代码来源:LocatorNavigationTargetHandlerFixture.cs

示例2: WhenViewExistsAndDoesNotImplementINavigationAware_ThenReturnsView

        public void WhenViewExistsAndDoesNotImplementINavigationAware_ThenReturnsView()
        {
            // Arrange

            var serviceLocatorMock = new Mock<IServiceLocator>();

            var region = new Region();

            var view = new TestView();

            region.Add(view);

            var navigationContext = new NavigationContext(null, new Uri(view.GetType().Name, UriKind.Relative));

            var navigationTargetHandler = new TestRegionNavigationContentLoader(serviceLocatorMock.Object);


            // Act

            var returnedView = navigationTargetHandler.LoadContent(region, navigationContext);


            // Assert

            Assert.AreSame(view, returnedView);
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:26,代码来源:LocatorNavigationTargetHandlerFixture.cs

示例3: WhenNavigatingWithQueryString_ViewIsActivated

        public void WhenNavigatingWithQueryString_ViewIsActivated()
        {
            // Prepare
            object view = new object();
            Uri viewUri = new Uri(view.GetType().Name + "?MyQuery=true", UriKind.Relative);

            IRegion region = new Region();
            region.Add(view);

            string regionName = "RegionName";
            RegionManager regionManager = new RegionManager();
            regionManager.Regions.Add(regionName, region);

            var serviceLocatorMock = new Mock<IServiceLocator>();
            serviceLocatorMock.Setup(x => x.GetInstance<IRegionNavigationJournalEntry>()).Returns(new RegionNavigationJournalEntry());

            IServiceLocator serviceLocator = serviceLocatorMock.Object;
            RegionNavigationContentLoader contentLoader = new RegionNavigationContentLoader(serviceLocator);
            IRegionNavigationJournal journal = new Mock<IRegionNavigationJournal>().Object;

            RegionNavigationService target = new RegionNavigationService(serviceLocator, contentLoader, journal);
            target.Region = region;

            // Act
            bool isNavigationSuccessful = false;
            target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true);

            // Verify
            Assert.IsTrue(isNavigationSuccessful);
            bool isViewActive = region.ActiveViews.Contains(view);
            Assert.IsTrue(isViewActive);
        }
开发者ID:CarlosVV,项目名称:mediavf,代码行数:32,代码来源:RegionNavigationServiceFixture.new.cs

示例4: CanAddAndRetrieveNamedViewInstance

        public void CanAddAndRetrieveNamedViewInstance()
        {
            IRegion region = new Region();
            object myView = new object();
            region.Add(myView, "MyView");
            object returnedView = region.GetView("MyView");

            Assert.IsNotNull(returnedView);
            Assert.AreSame(returnedView, myView);
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:10,代码来源:RegionFixture.cs

示例5: CanAddContentToRegion

        public void CanAddContentToRegion()
        {
            IRegion region = new Region();

            Assert.AreEqual(0, region.Views.Cast<object>().Count());

            region.Add(new object());

            Assert.AreEqual(1, region.Views.Cast<object>().Count());
        }
开发者ID:ZeroInfinite,项目名称:PortablePrism,代码行数:10,代码来源:RegionFixture.cs

示例6: CanRemoveContentFromRegion

        public void CanRemoveContentFromRegion()
        {
            IRegion region = new Region();
            object view = new object();

            region.Add(view);
            region.Remove(view);

            Assert.AreEqual(0, region.Views.Cast<object>().Count());
        }
开发者ID:ZeroInfinite,项目名称:PortablePrism,代码行数:10,代码来源:RegionFixture.cs

示例7: RegionExposesCollectionOfContainedViews

        public void RegionExposesCollectionOfContainedViews()
        {
            IRegion region = new Region();

            object view = new object();

            region.Add(view);

            var views = region.Views;

            Assert.IsNotNull(views);
            Assert.AreEqual(1, views.Cast<object>().Count());
            Assert.AreSame(view, views.Cast<object>().ElementAt(0));
        }
开发者ID:ZeroInfinite,项目名称:PortablePrism,代码行数:14,代码来源:RegionFixture.cs

示例8: ShouldFindCandidateViewWithFriendlyNameInRegion

        public void ShouldFindCandidateViewWithFriendlyNameInRegion()
        {
            this.ConfigureMockServiceLocator();

            // We cannot access the MefRegionNavigationContentLoader directly so we need to call its
            // GetCandidatesFromRegion method through a navigation request.
            IRegion testRegion = new Region();

            MockView2 view = new MockView2();
            testRegion.Add(view);
            testRegion.Deactivate(view);

            testRegion.RequestNavigate("SomeView");

            Assert.IsTrue(testRegion.Views.Contains(view));
            Assert.IsTrue(testRegion.Views.Count() == 1);
            Assert.IsTrue(testRegion.ActiveViews.Count() == 1);
            Assert.IsTrue(testRegion.ActiveViews.Contains(view));
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:19,代码来源:MefRegionNavigationContentLoaderFixture.cs

示例9: WhenClearChildViewsPropertyIsNotSet_ThenChildViewsRegionManagerIsNotCleared

        public void WhenClearChildViewsPropertyIsNotSet_ThenChildViewsRegionManagerIsNotCleared()
        {
            var regionManager = new MockRegionManager();

            var region = new Region();
            region.RegionManager = regionManager;

            var behavior = new ClearChildViewsRegionBehavior();
            behavior.Region = region;
            behavior.Attach();

            var childView = new MockFrameworkElement();
            region.Add(childView);

            Assert.AreEqual(regionManager, childView.GetValue(RegionManager.RegionManagerProperty));

            region.RegionManager = null;

            Assert.AreEqual(regionManager, childView.GetValue(RegionManager.RegionManagerProperty));
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:20,代码来源:ClearChildViewsRegionBehaviorFixture.cs

示例10: WhenClearChildViewsPropertyIsNotSet_ThenChildViewsRegionManagerIsNotCleared

        public async Task WhenClearChildViewsPropertyIsNotSet_ThenChildViewsRegionManagerIsNotCleared()
        {
            await ExecuteOnUIThread(() =>
                {
                    var regionManager = new MockRegionManager();

                    var region = new Region() { RegionManager = regionManager };

                    var behavior = new ClearChildViewsRegionBehavior() { Region = region };
                    behavior.Attach();

                    var childView = new MockFrameworkElement();
                    region.Add(childView);

                    Assert.AreEqual(regionManager, childView.GetValue(RegionManager.RegionManagerProperty));

                    region.RegionManager = null;

                    Assert.AreEqual(regionManager, childView.GetValue(RegionManager.RegionManagerProperty));
                });
        }
开发者ID:ZeroInfinite,项目名称:PortablePrism,代码行数:21,代码来源:ClearChildViewsRegionBehaviorFixture.cs

示例11: ShouldFindCandidateViewInRegion

        public void ShouldFindCandidateViewInRegion()
        {
            IUnityContainer container = new UnityContainer();
            container.RegisterType<object, MockView>("MockView");

            this.ConfigureMockServiceLocator(container);

            // We cannot access the UnityRegionNavigationContentLoader directly so we need to call its
            // GetCandidatesFromRegion method through a navigation request.
            IRegion testRegion = new Region();

            MockView view = new MockView();
            testRegion.Add(view);
            testRegion.Deactivate(view);

            testRegion.RequestNavigate("MockView");

            Assert.IsTrue(testRegion.Views.Contains(view));
            Assert.IsTrue(testRegion.Views.Count() == 1);
            Assert.IsTrue(testRegion.ActiveViews.Count() == 1);
            Assert.IsTrue(testRegion.ActiveViews.Contains(view));
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:22,代码来源:UnityRegionNavigationContentLoaderFixture.cs

示例12: AddingSameViewTwiceThrows

        public void AddingSameViewTwiceThrows()
        {
            object view = new object();
            IRegion region = new Region();
            region.Add(view);

            try
            {
                region.Add(view);
                Assert.Fail();
            }
            catch (InvalidOperationException ex)
            {
                Assert.AreEqual("View already exists in region.", ex.Message);
            }
            catch
            {
                Assert.Fail();
            }
        }
开发者ID:ZeroInfinite,项目名称:PortablePrism,代码行数:20,代码来源:RegionFixture.cs

示例13: ShowViewFiresViewShowedEvent

        public void ShowViewFiresViewShowedEvent()
        {
            bool viewActivated = false;

            IRegion region = new Region();
            object model = new object();
            region.ActiveViews.CollectionChanged += (o, e) =>
                                                        {
                                                            if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems.Contains(model))
                                                                viewActivated = true;
                                                        };
            region.Add(model);
            Assert.IsFalse(viewActivated);

            region.Activate(model);

            Assert.IsTrue(viewActivated);
        }
开发者ID:ZeroInfinite,项目名称:PortablePrism,代码行数:18,代码来源:RegionFixture.cs

示例14: ViewRemovedEventPassesTheViewRemovedInTheEventArgs

        public void ViewRemovedEventPassesTheViewRemovedInTheEventArgs()
        {
            object removedView = null;

            IRegion region = new Region();
            region.Views.CollectionChanged += (sender, e) =>
                                                  {
                                                      if (e.Action == NotifyCollectionChangedAction.Remove)
                                                          removedView = e.OldItems[0];
                                                  };
            object model = new object();
            region.Add(model);
            Assert.IsNull(removedView);

            region.Remove(model);

            Assert.AreSame(model, removedView);
        }
开发者ID:ZeroInfinite,项目名称:PortablePrism,代码行数:18,代码来源:RegionFixture.cs

示例15: AddNamedViewIsAlsoListedInViewsCollection

        public void AddNamedViewIsAlsoListedInViewsCollection()
        {
            IRegion region = new Region();
            object myView = new object();

            region.Add(myView, "MyView");

            Assert.AreEqual(1, region.Views.Cast<object>().Count());
            Assert.AreSame(myView, region.Views.Cast<object>().ElementAt(0));
        }
开发者ID:ZeroInfinite,项目名称:PortablePrism,代码行数:10,代码来源:RegionFixture.cs


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