public ConnectionElement GetElementByKey(string key)
        {
            IEnumerator ie = this.GetEnumerator();

            while (ie.MoveNext())
            {
                ConnectionElement element = (ConnectionElement)ie.Current;
                if (element.Name == key)
                {
                    return(element);
                }
            }
            return(null);
        }
        /// <summary>
        /// Gets the element key for a specified configuration element when overridden in a derived class.
        /// </summary>
        /// <param name="element">The <see cref="T:ConfigurationElement"/> to return the key for. </param>
        /// <returns>An <see cref="T:Object"/> that acts as the key for the specified <see cref="T:ConfigurationElement"/>.</returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            ConnectionElement se = (ConnectionElement)element;

            return(se.Name);
        }
예제 #3
0
        public void Change(string key)
        {
            ConnectionProvidersSection serviceproviders = System.Configuration.ConfigurationManager.GetSection("ConnectionProviders") as ConnectionProvidersSection;

            current = serviceproviders.Providers.GetElementByKey(key);
        }