/V4/PrismLibrary/Desktop/Prism/Modularity/ModuleDependencyCollection.Desktop.cs

# · C# · 104 lines · 42 code · 8 blank · 54 comment · 2 complexity · 16e0d9710f0a0ff68dd4d66347128efa 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.Configuration;
  19. namespace Microsoft.Practices.Prism.Modularity
  20. {
  21. /// <summary>
  22. /// A collection of <see cref="ModuleDependencyConfigurationElement"/>.
  23. /// </summary>
  24. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
  25. public class ModuleDependencyCollection : ConfigurationElementCollection
  26. {
  27. /// <summary>
  28. /// Initializes a new instance of <see cref="ModuleDependencyCollection"/>.
  29. /// </summary>
  30. public ModuleDependencyCollection()
  31. {
  32. }
  33. /// <summary>
  34. /// Initializes a new instance of <see cref="ModuleDependencyCollection"/>.
  35. /// </summary>
  36. /// <param name="dependencies">An array of <see cref="ModuleDependencyConfigurationElement"/> with initial list of dependencies.</param>
  37. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
  38. public ModuleDependencyCollection(ModuleDependencyConfigurationElement[] dependencies)
  39. {
  40. if (dependencies == null)
  41. throw new ArgumentNullException("dependencies");
  42. foreach (ModuleDependencyConfigurationElement dependency in dependencies)
  43. {
  44. BaseAdd(dependency);
  45. }
  46. }
  47. ///<summary>
  48. ///Gets the type of the <see cref="T:System.Configuration.ConfigurationElementCollection" />.
  49. ///</summary>
  50. ///<value>
  51. ///The <see cref="T:System.Configuration.ConfigurationElementCollectionType" /> of this collection.
  52. ///</value>
  53. public override ConfigurationElementCollectionType CollectionType
  54. {
  55. get { return ConfigurationElementCollectionType.BasicMap; }
  56. }
  57. ///<summary>
  58. ///Gets the name used to identify this collection of elements in the configuration file when overridden in a derived class.
  59. ///</summary>
  60. ///<value>
  61. ///The name of the collection; otherwise, an empty string.
  62. ///</value>
  63. protected override string ElementName
  64. {
  65. get { return "dependency"; }
  66. }
  67. /// <summary>
  68. /// Gets the <see cref="ModuleDependencyConfigurationElement"/> located at the specified index in the collection.
  69. /// </summary>
  70. /// <param name="index">The index of the element in the collection.</param>
  71. /// <returns>A <see cref="ModuleDependencyConfigurationElement"/>.</returns>
  72. public ModuleDependencyConfigurationElement this[int index]
  73. {
  74. get { return (ModuleDependencyConfigurationElement)base.BaseGet(index); }
  75. }
  76. /// <summary>
  77. /// Creates a new <see cref="ModuleDependencyConfigurationElement"/>.
  78. /// </summary>
  79. /// <returns>A <see cref="ModuleDependencyConfigurationElement"/>.</returns>
  80. protected override ConfigurationElement CreateNewElement()
  81. {
  82. return new ModuleDependencyConfigurationElement();
  83. }
  84. ///<summary>
  85. ///Gets the element key for a specified configuration element when overridden in a derived class.
  86. ///</summary>
  87. ///<param name="element">The <see cref="T:System.Configuration.ConfigurationElement" /> to return the key for. </param>
  88. ///<returns>
  89. ///An <see cref="T:System.Object" /> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement" />.
  90. ///</returns>
  91. protected override object GetElementKey(ConfigurationElement element)
  92. {
  93. return ((ModuleDependencyConfigurationElement)element).ModuleName;
  94. }
  95. }
  96. }