PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/V4/Quickstarts/Modularity/Desktop/ModularityWithMef/ModuleC/ModuleC.cs

#
C# | 57 lines | 27 code | 4 blank | 26 comment | 2 complexity | 7d13c9deb015769b7703d35f0a35895d 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 System;
  18. using System.ComponentModel.Composition;
  19. using Microsoft.Practices.Prism.MefExtensions.Modularity;
  20. using Microsoft.Practices.Prism.Modularity;
  21. using ModuleTracking;
  22. namespace ModularityWithMef.Desktop
  23. {
  24. /// <summary>
  25. /// A module for the quickstart.
  26. /// </summary>
  27. [ModuleExport(typeof(ModuleC), InitializationMode = InitializationMode.OnDemand)]
  28. public class ModuleC : IModule
  29. {
  30. private readonly IModuleTracker moduleTracker;
  31. /// <summary>
  32. /// Initializes a new instance of the <see cref="ModuleC"/> class.
  33. /// </summary>
  34. /// <param name="moduleTracker">The module tracker.</param>
  35. [ImportingConstructor]
  36. public ModuleC(IModuleTracker moduleTracker)
  37. {
  38. if (moduleTracker == null)
  39. {
  40. throw new ArgumentNullException("moduleTracker");
  41. }
  42. this.moduleTracker = moduleTracker;
  43. this.moduleTracker.RecordModuleConstructed(WellKnownModuleNames.ModuleC);
  44. }
  45. /// <summary>
  46. /// Notifies the module that it has be initialized.
  47. /// </summary>
  48. public void Initialize()
  49. {
  50. this.moduleTracker.RecordModuleInitialized(WellKnownModuleNames.ModuleC);
  51. }
  52. }
  53. }