PageRenderTime 25ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/Quickstarts/EventAggregation/Desktop/ModuleB/ModuleB.cs

#
C# | 55 lines | 31 code | 8 blank | 16 comment | 0 complexity | 33a1aa5c9157a2dfa06b2144898aec3c MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 4//===================================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===================================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===================================================================================
17using Microsoft.Practices.Prism.Modularity;
18using Microsoft.Practices.Prism.Regions;
19using Microsoft.Practices.Unity;
20
21namespace ModuleB
22{
23    public class ModuleB : IModule
24    {
25        public ModuleB(IUnityContainer container, IRegionManager regionManager)
26        {
27            Container = container;
28            RegionManager = regionManager;
29            
30            RegisterViewsAndServices();
31        }
32
33        private void RegisterViewsAndServices()
34        {
35            this.Container.RegisterType<IActivityView, ActivityView>();
36        }
37
38        public void Initialize()
39        {
40            ActivityView activityView1 = Container.Resolve<ActivityView>();
41            ActivityView activityView2 = Container.Resolve<ActivityView>();
42
43            activityView1.SetCustomerId("Customer1");
44            activityView2.SetCustomerId("Customer2");
45
46            IRegion rightRegion = RegionManager.Regions["RightRegion"];
47            rightRegion.Add(activityView1);
48            rightRegion.Add(activityView2);
49        }
50
51        public IUnityContainer Container { get; private set; }
52
53        public IRegionManager RegionManager { get; private set; }
54    }
55}