PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 0ms 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. 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.Services;
  23. using StockTraderRI.Modules.Watch.WatchList;
  24. namespace StockTraderRI.Modules.Watch
  25. {
  26. public class WatchModule : IModule
  27. {
  28. private readonly IUnityContainer _container;
  29. private readonly IRegionManager _regionManager;
  30. public WatchModule(IUnityContainer container, IRegionManager regionManager)
  31. {
  32. _container = container;
  33. _regionManager = regionManager;
  34. }
  35. #region IModule Members
  36. public void Initialize()
  37. {
  38. RegisterViewsAndServices();
  39. IWatchListPresentationModel watchListPresentationModel = _container.Resolve<IWatchListPresentationModel>();
  40. _regionManager.Regions[RegionNames.WatchRegion].Add(watchListPresentationModel.View);
  41. IAddWatchPresenter addWatchPresenter = _container.Resolve<IAddWatchPresenter>();
  42. _regionManager.Regions[RegionNames.MainToolbarRegion].Add(addWatchPresenter.View);
  43. }
  44. protected void RegisterViewsAndServices()
  45. {
  46. _container.RegisterType<IWatchListService, WatchListService>(new ContainerControlledLifetimeManager());
  47. _container.RegisterType<IWatchListView, WatchListView>();
  48. _container.RegisterType<IWatchListPresentationModel, WatchListPresentationModel>();
  49. _container.RegisterType<IAddWatchView, AddWatchView>();
  50. _container.RegisterType<IAddWatchPresenter, AddWatchPresenter>();
  51. }
  52. #endregion
  53. }
  54. }