PageRenderTime 24ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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