Exemplo n.º 1
0
        private void SetConnectionStrings()
        {
            _preInjectConnectionStrings = DefaultConfiguration.GetConnectionStrings();
            Dictionary <string, ConnectionStringSettings> connectionStrings = new Dictionary <string, ConnectionStringSettings>();

            foreach (ConnectionStringSettings conn in _preInjectConnectionStrings)
            {
                connectionStrings.Add(conn.Name, new ConnectionStringSettings(conn.Name, conn.ConnectionString, conn.ProviderName));
            }

            foreach (ConnectionStringValue conn in ConnectionStrings.Values)
            {
                ConnectionStringSettings val = new ConnectionStringSettings();
                val.Name             = conn.ConnectionString.Key;
                val.ConnectionString = conn.ConnectionString.Value;
                val.ProviderName     = conn.Provider;
                if (connectionStrings.ContainsKey(val.Name))
                {
                    connectionStrings[val.Name] = val;
                }
                else
                {
                    connectionStrings.Add(val.Name, val);
                }
            }

            DefaultConfiguration.SetConnectionStrings(connectionStrings.Values.ToArray());
        }