PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/V1/trunk/Source/StockTraderRI/StockTraderRI.Modules.WatchList/WatchModule.cs

#
C# | 62 lines | 38 code | 8 blank | 16 comment | 0 complexity | 46639fcb7d32bfa7707f80c7bb5ae944 MD5 | raw file
 1//===============================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation
 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//===============================================================================
17
18using Microsoft.Practices.Composite.Modularity;
19using Microsoft.Practices.Composite.Regions;
20using Microsoft.Practices.Unity;
21using StockTraderRI.Infrastructure;
22using StockTraderRI.Modules.Watch.AddWatch;
23using StockTraderRI.Modules.Watch.Services;
24using StockTraderRI.Modules.Watch.WatchList;
25
26namespace StockTraderRI.Modules.Watch
27{
28    public class WatchModule : IModule
29    {
30        private readonly IUnityContainer _container;
31        private readonly IRegionManager _regionManager;
32
33        public WatchModule(IUnityContainer container, IRegionManager regionManager)
34        {
35            _container = container;
36            _regionManager = regionManager;
37        }
38
39        #region IModule Members
40
41        public void Initialize()
42        {
43            RegisterViewsAndServices();
44
45            IWatchListPresentationModel watchListPresentationModel = _container.Resolve<IWatchListPresentationModel>();
46            _regionManager.Regions[RegionNames.WatchRegion].Add(watchListPresentationModel.View);
47            IAddWatchPresenter addWatchPresenter = _container.Resolve<IAddWatchPresenter>();
48            _regionManager.Regions[RegionNames.MainToolbarRegion].Add(addWatchPresenter.View);
49        }
50
51        protected void RegisterViewsAndServices()
52        {
53            _container.RegisterType<IWatchListService, WatchListService>(new ContainerControlledLifetimeManager());
54            _container.RegisterType<IWatchListView, WatchListView>();
55            _container.RegisterType<IWatchListPresentationModel, WatchListPresentationModel>();
56            _container.RegisterType<IAddWatchView, AddWatchView>();
57            _container.RegisterType<IAddWatchPresenter, AddWatchPresenter>();
58        }
59
60        #endregion
61    }
62}