private static void AddOption(MyCatConnectionStringOption option)
 {
     foreach (string key in option.m_keys)
     {
         s_options.Add(key, option);
     }
 }
        static MyCatConnectionStringOption()
        {
            s_options = new Dictionary <string, MyCatConnectionStringOption>(StringComparer.OrdinalIgnoreCase);

            // Base Options
            AddOption(Server = new MyCatConnectionStringOption <string>(
                          keys: new[] { "Server", "Host", "Data Source", "DataSource", "Address", "Addr", "Network Address" },
                          defaultValue: ""));

            AddOption(Port = new MyCatConnectionStringOption <uint>(
                          keys: new[] { "Port" },
                          defaultValue: 3306u));

            AddOption(UserID = new MyCatConnectionStringOption <string>(
                          keys: new[] { "User Id", "UserID", "Username", "Uid", "User name", "User" },
                          defaultValue: ""));

            AddOption(Password = new MyCatConnectionStringOption <string>(
                          keys: new[] { "Password", "pwd" },
                          defaultValue: ""));

            AddOption(Database = new MyCatConnectionStringOption <string>(
                          keys: new[] { "Database", "Initial Catalog" },
                          defaultValue: ""));

            // SSL/TLS Options
            AddOption(SslMode = new MyCatConnectionStringOption <MyCatSslMode>(
                          keys: new[] { "SSL Mode", "SslMode" },
                          defaultValue: MyCatSslMode.None));

            AddOption(CertificateFile = new MyCatConnectionStringOption <string>(
                          keys: new[] { "CertificateFile", "Certificate File" },
                          defaultValue: null));

            AddOption(CertificatePassword = new MyCatConnectionStringOption <string>(
                          keys: new[] { "CertificatePassword", "Certificate Password" },
                          defaultValue: null));

            // Connection Pooling Options
            AddOption(Pooling = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "Pooling" },
                          defaultValue: true));

            AddOption(ConnectionReset = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "Connection Reset", "ConnectionReset" },
                          defaultValue: true));

            AddOption(MinimumPoolSize = new MyCatConnectionStringOption <uint>(
                          keys: new[] { "Minimum Pool Size", "Min Pool Size", "MinimumPoolSize", "minpoolsize" },
                          defaultValue: 0));

            AddOption(MaximumPoolSize = new MyCatConnectionStringOption <uint>(
                          keys: new[] { "Maximum Pool Size", "Max Pool Size", "MaximumPoolSize", "maxpoolsize" },
                          defaultValue: 100));

            // Other Options
            AddOption(AllowUserVariables = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "AllowUserVariables", "Allow User Variables" },
                          defaultValue: true));

            AddOption(CharacterSet = new MyCatConnectionStringOption <string>(
                          keys: new[] { "CharSet", "Character Set", "CharacterSet" },
                          defaultValue: ""));

            AddOption(ConnectionTimeout = new MyCatConnectionStringOption <uint>(
                          keys: new[] { "Connection Timeout", "ConnectionTimeout", "Connect Timeout" },
                          defaultValue: 15u));

            AddOption(ConvertZeroDateTime = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "Convert Zero Datetime", "ConvertZeroDateTime" },
                          defaultValue: false));

            AddOption(ForceSynchronous = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "ForceSynchronous" },
                          defaultValue: false));

            AddOption(Keepalive = new MyCatConnectionStringOption <uint>(
                          keys: new[] { "Keep Alive", "Keepalive" },
                          defaultValue: 0u));

            AddOption(OldGuids = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "Old Guids", "OldGuids" },
                          defaultValue: false));

            AddOption(PersistSecurityInfo = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "Persist Security Info", "PersistSecurityInfo" },
                          defaultValue: false));

            AddOption(TreatTinyAsBoolean = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "Treat Tiny As Boolean", "TreatTinyAsBoolean" },
                          defaultValue: true));

            AddOption(UseAffectedRows = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "Use Affected Rows", "UseAffectedRows" },
                          defaultValue: false));

            AddOption(UseCompression = new MyCatConnectionStringOption <bool>(
                          keys: new[] { "Compress", "Use Compression", "UseCompression" },
                          defaultValue: false));
        }
 public override object this[string key]
 {
     get { return(MyCatConnectionStringOption.GetOptionForKey(key).GetObject(this)); }
     set { base[MyCatConnectionStringOption.GetOptionForKey(key).Key] = Convert.ToString(value, CultureInfo.InvariantCulture); }
 }
        public override bool Remove(string key)
        {
            var option = MyCatConnectionStringOption.TryGetOptionForKey(key);

            return(option != null && base.Remove(option.Key));
        }