PageRenderTime 40ms CodeModel.GetById 19ms RepoModel.GetById 0ms 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. //===================================================================================
  17. using Microsoft.Practices.Composite.Modularity;
  18. using Microsoft.Practices.Composite.Regions;
  19. using Microsoft.Practices.Unity;
  20. using StockTraderRI.Infrastructure;
  21. using StockTraderRI.Modules.Watch.AddWatch;
  22. using StockTraderRI.Modules.Watch.Controllers;
  23. using StockTraderRI.Modules.Watch.Services;
  24. using StockTraderRI.Modules.Watch.WatchList;
  25. namespace StockTraderRI.Modules.Watch
  26. {
  27. public class WatchModule : IModule
  28. {
  29. private readonly IUnityContainer _container;
  30. private readonly IRegionManager _regionManager;
  31. public WatchModule(IUnityContainer container, IRegionManager regionManager)
  32. {
  33. _container = container;
  34. _regionManager = regionManager;
  35. }
  36. #region IModule Members
  37. public void Initialize()
  38. {
  39. this.RegisterViewsAndServices();
  40. var controller = this._container.Resolve<IWatchListController>();
  41. controller.Run();
  42. this._regionManager.RegisterViewWithRegion(
  43. RegionNames.MainToolBarRegion,
  44. () => this._container.Resolve<IAddWatchPresenter>().View);
  45. }
  46. protected void RegisterViewsAndServices()
  47. {
  48. _container.RegisterType<IWatchListController, WatchListController>();
  49. _container.RegisterType<IWatchListService, WatchListService>(new ContainerControlledLifetimeManager());
  50. _container.RegisterType<IWatchListView, WatchListView>();
  51. _container.RegisterType<IWatchListPresentationModel, WatchListPresentationModel>();
  52. _container.RegisterType<IAddWatchView, AddWatchView>();
  53. _container.RegisterType<IAddWatchPresenter, AddWatchPresenter>();
  54. }
  55. #endregion
  56. }
  57. }