// Copyright ?2013, 2018, Oracle and/or its affiliates. All rights reserved. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License, version 2.0, as // published by the Free Software Foundation. // // This program is also distributed with certain software (including // but not limited to OpenSSL) that is licensed under separate terms, // as designated in a particular file or component or in included license // documentation. The authors of MySQL hereby grant you an // additional permission to link the program and your derivative works // with the separately licensed software that they have included with // MySQL. // // Without limiting anything contained in the foregoing, this file, // which is part of MySQL Connector/NET, is also subject to the // Universal FOSS Exception, version 1.0, a copy of which can be found at // http://oss.oracle.com/licenses/universal-foss-exception. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU General Public License, version 2.0, for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #if !NETCOREAPP using System; using System.Collections.Generic; using System.Text; using System.Configuration; namespace MySql.Data.MySqlClient { /// /// Represents a section within a configuration file. /// public sealed class MySqlConfiguration : ConfigurationSection { private static MySqlConfiguration settings = ConfigurationManager.GetSection("MySQL") as MySqlConfiguration; /// /// Gets the MySQL configuations associated to the current configuration. /// public static MySqlConfiguration Settings { get { return settings; } } /// /// Gets a collection of the exception interceptors available in the current configuration. /// [ConfigurationProperty("ExceptionInterceptors", IsRequired = false)] [ConfigurationCollection(typeof(InterceptorConfigurationElement), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")] public GenericConfigurationElementCollection ExceptionInterceptors { get { return (GenericConfigurationElementCollection)this["ExceptionInterceptors"]; } } /// /// Gets a collection of the command interceptors available in the current configuration. /// [ConfigurationProperty("CommandInterceptors", IsRequired = false)] [ConfigurationCollection(typeof(InterceptorConfigurationElement), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")] public GenericConfigurationElementCollection CommandInterceptors { get { return (GenericConfigurationElementCollection)this["CommandInterceptors"]; } } /// /// Gets a collection of the authentication plugins available in the current configuration. /// [ConfigurationProperty("AuthenticationPlugins", IsRequired = false)] [ConfigurationCollection(typeof(AuthenticationPluginConfigurationElement), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")] public GenericConfigurationElementCollection AuthenticationPlugins { get { return (GenericConfigurationElementCollection)this["AuthenticationPlugins"]; } } /// /// Gets or sets the replication configurations. /// [ConfigurationProperty("Replication", IsRequired = true)] public ReplicationConfigurationElement Replication { get { return (ReplicationConfigurationElement)this["Replication"]; } set { this["Replication"] = value; } } } /// /// Defines the configurations allowed for an authentication plugin. /// public sealed class AuthenticationPluginConfigurationElement : ConfigurationElement { /// /// Gets or sets the name of the authentication plugin. /// [ConfigurationProperty("name", IsRequired = true)] public string Name { get { return (string)this["name"]; } set { this["name"] = value; } } /// /// Gets or sets the type of the authentication plugin. /// [ConfigurationProperty("type", IsRequired = true)] public string Type { get { return (string)this["type"]; } set { this["type"] = value; } } } /// /// Defines the configurations allowed for an interceptor. /// public sealed class InterceptorConfigurationElement : ConfigurationElement { /// /// Gets or sets the name of the interceptor. /// [ConfigurationProperty("name", IsRequired = true)] public string Name { get { return (string)this["name"]; } set { this["name"] = value; } } /// /// Gets or sets the type of the interceptor. /// [ConfigurationProperty("type", IsRequired = true)] public string Type { get { return (string)this["type"]; } set { this["type"] = value; } } } /// /// Represents a generic configuration element. /// /// public sealed class GenericConfigurationElementCollection : ConfigurationElementCollection, IEnumerable where T : ConfigurationElement, new() { List _elements = new List(); protected override ConfigurationElement CreateNewElement() { T newElement = new T(); _elements.Add(newElement); return newElement; } protected override object GetElementKey(ConfigurationElement element) { return _elements.Find(e => e.Equals(element)); } /// /// Gets an enumerator that iterates through the returned list. /// /// An enumerator that iterates through the returned list. public new IEnumerator GetEnumerator() { return _elements.GetEnumerator(); } } } #endif