示例#1
0
        public static SqlConnectionFormProxy GetInstance()
        {
            if (_singleton == null)
            {
                _singleton = new SqlConnectionFormProxy();
            }

            return(_singleton);
        }
示例#2
0
        public SqlConnectionForm(
            Dictionary <String, SqlConnection> sqlConnections,
            string id)
        {
            InitializeComponent();

            _sqlConnectionManager = SqlConnectionManager.GetInstance();
            _sqlConnections       = sqlConnections;
            _connectionId         = id;

            foreach (SqlDataProvider provider in
                     _sqlConnectionManager.SqlDataProviders.Values)
            {
                _providerComboBox.Items.Add(provider);
            }

            if (_providerComboBox.Items.Count > 0)
            {
                _providerComboBox.SelectedIndex = 0;
            }

            if (_connectionId != null)
            {
                if (!_sqlConnections.ContainsKey(id))
                {
                    throw new Exception("Invalid connection ID");
                }

                SqlConnection connection = _sqlConnections[id];
                _nameTextBox.Text             = connection.Name;
                _connectionStringTextBox.Text =
                    connection.ConnectionStringForEditing;

                SelectedProviderByInvariantName(
                    connection.Provider.InvariantName);
            }

            // Allow client applications to modify the form.
            SqlConnectionFormProxy.GetInstance().
            UpdateFormControls(Controls);
        }