PageRenderTime 47ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/V2/trunk/RI/Desktop/StockTraderRI.Modules.Market/MarketModule.cs

#
C# | 57 lines | 34 code | 7 blank | 16 comment | 0 complexity | 19c641008ec7c3c3d14b15a06fa6357c 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.Infrastructure.Interfaces;
22using StockTraderRI.Modules.Market.Services;
23using StockTraderRI.Modules.Market.TrendLine;
24
25namespace StockTraderRI.Modules.Market
26{
27    public class MarketModule : IModule
28    {
29        private readonly IUnityContainer container;
30        private readonly IRegionManager regionManager;
31
32        public MarketModule(IUnityContainer container, IRegionManager regionManager)
33        {
34            this.container = container;
35            this.regionManager = regionManager;
36        }
37
38        #region IModule Members
39
40        public void Initialize()
41        {
42            RegisterViewsAndServices();
43
44            this.regionManager.RegisterViewWithRegion(RegionNames.ResearchRegion, () => this.container.Resolve<ITrendLinePresentationModel>().View);
45        }
46
47        protected void RegisterViewsAndServices()
48        {
49            container.RegisterType<IMarketHistoryService, MarketHistoryService>(new ContainerControlledLifetimeManager());
50            container.RegisterType<IMarketFeedService, MarketFeedService>(new ContainerControlledLifetimeManager());
51            container.RegisterType<ITrendLineView, TrendLineView>();
52            container.RegisterType<ITrendLinePresentationModel, TrendLinePresentationModel>();
53        }
54
55        #endregion
56    }
57}