コード例 #1
0
        public void WhenAttached_ThenAddsViewsRegisteredToTheRegion()
        {
            AggregateCatalog catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(AutoPopulateExportedViewsBehavior).Assembly));
            catalog.Catalogs.Add(new TypeCatalog(typeof(View1), typeof(View2)));
            CompositionContainer container = new CompositionContainer(catalog);

            AutoPopulateExportedViewsBehavior behavior = container.GetExportedValue <AutoPopulateExportedViewsBehavior>();

            Region region = new Region()
            {
                Name = "region1"
            };

            region.Behaviors.Add("", behavior);

            Assert.AreEqual(1, region.Views.Cast <object>().Count());
            Assert.IsTrue(region.Views.Cast <object>().Any(e => e.GetType() == typeof(View1)));
        }
コード例 #2
0
        public void AutoPopulateButtonPanel()
        {
            Assert.Inconclusive("The test must be adopted from the RI - container cannot be created because there are errors for imports satisfied by IRegionManager export.");
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(Shell).Assembly));
            CompositionContainer container = new CompositionContainer(catalog);
            IEnumerable <object> _v1       = container.GetExportedValues <object>();

            Assert.IsNotNull(_v1);
            Assert.AreEqual <int>(2, _v1.Count <object>());

            AutoPopulateExportedViewsBehavior behavior = container.GetExportedValue <AutoPopulateExportedViewsBehavior>();
            Region region = new Region()
            {
                Name = RegionNames.ButtonsRegion
            };

            region.Behaviors.Add("", behavior);
            Assert.AreEqual(1, region.Views.Cast <object>().Count());
            Assert.IsTrue(region.Views.Cast <object>().Any(e => e.GetType() == typeof(ButtonsPanel)));
        }
コード例 #3
0
ファイル: LayoutManager.cs プロジェクト: jiailiuyan/work
 public LayoutManager(IEventAggregator eventaggregator, IShell shell, AutoPopulateExportedViewsBehavior viewsmanager)
 {
     this.eventAggregator = eventaggregator;
     this.shell           = shell;
     this.viewsManager    = viewsmanager;
 }