PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/V2.2/trunk/RI/Desktop/StockTraderRI.Modules.WatchList/WatchModule.cs

#
C# | 67 lines | 41 code | 10 blank | 16 comment | 0 complexity | e668e853a8a6250c296c68bd3e520cc2 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.Composite.Modularity;
18using Microsoft.Practices.Composite.Regions;
19using Microsoft.Practices.Unity;
20using StockTraderRI.Infrastructure;
21using StockTraderRI.Modules.Watch.AddWatch;
22using StockTraderRI.Modules.Watch.Controllers;
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            this.RegisterViewsAndServices();
44
45            var controller = this._container.Resolve<IWatchListController>();
46            controller.Run();
47
48            this._regionManager.RegisterViewWithRegion(
49                                                    RegionNames.MainToolBarRegion,
50                                                    () => this._container.Resolve<IAddWatchPresenter>().View);
51        }
52
53        protected void RegisterViewsAndServices()
54        {
55            _container.RegisterType<IWatchListController, WatchListController>();
56            _container.RegisterType<IWatchListService, WatchListService>(new ContainerControlledLifetimeManager());
57
58            _container.RegisterType<IWatchListView, WatchListView>();
59            _container.RegisterType<IWatchListPresentationModel, WatchListPresentationModel>();
60
61            _container.RegisterType<IAddWatchView, AddWatchView>();
62            _container.RegisterType<IAddWatchPresenter, AddWatchPresenter>();
63        }
64
65        #endregion
66    }
67}