/// <summary>The add to list.</summary>
 /// <param name="definition">The definition.</param>
 private void AddToList(DbConnectionDefinition definition)
 {
     if (!lstConnections.Items.Contains(definition))
     {
         lstConnections.Items.Add(definition);
     }
 }
 /// <summary>Initializes a new instance of the <see cref="ConnectionStringBuilderForm"/> class.</summary>
 /// <param name="hostWindow">The host window.</param>
 /// <param name="definition">The definition.</param>
 /// <param name="services">The services.</param>
 public ConnectionStringBuilderForm(IHostWindow hostWindow, DbConnectionDefinition definition, IApplicationServices services)
     : this(hostWindow, services)
 {
     ConnectionDefinition = definition;
     ConnectionName = ConnectionDefinition.Name;
     Comments = ConnectionDefinition.Comment;
     _initProvider = ConnectionDefinition.ProviderName;
     _connStr = ConnectionDefinition.ConnectionString;
 }
 /// <summary>
 /// 	Initializes static members of the <see cref = "DbConnectionDefinition" /> class.
 /// </summary>
 static DbConnectionDefinition()
 {
     Default = new DbConnectionDefinition
               	{
               		Name = "Default - MSSQL Master@localhost",
               		ProviderName = "System.Data.SqlClient",
               		ConnectionString = @"Server=.; Database=Master; Integrated Security=SSPI"
               	};
 }
Exemplo n.º 4
0
 /// <summary>
 ///     Initializes static members of the <see cref = "DbConnectionDefinition" /> class.
 /// </summary>
 static DbConnectionDefinition()
 {
     Default = new DbConnectionDefinition
     {
         Name             = "Default - MSSQL Master@localhost",
         ProviderName     = "System.Data.SqlClient",
         ConnectionString = @"Server=.; Database=Master; Integrated Security=SSPI"
     };
 }
 public void Can_remove_a_DbConnectionDefinition_object()
 {
     DbConnectionDefinitionList definitionList = new DbConnectionDefinitionList();
     definitionList.DefaultName = "def";
     var conn1 = new DbConnectionDefinition {ConnectionString = "cs1", Name = "nm1", ProviderName = "p1"};
     var conn2 = new DbConnectionDefinition {ConnectionString = "cs2", Name = "nm2", ProviderName = "p2"};
     var conn3unused = new DbConnectionDefinition {ConnectionString = "cs3", Name = "nm3", ProviderName = "p3"};
     definitionList.Definitions = new[] {conn1, conn2};
     Assert.That(definitionList.Definitions.Length, Is.EqualTo(2));
     bool remove1=definitionList.RemoveDefinition(conn2);
     Assert.That(remove1, Is.EqualTo(true));
     Assert.That(definitionList.Definitions.Length, Is.EqualTo(1));
     Assert.That(definitionList.Definitions[0].Name, Is.EqualTo("nm1"));
     bool remove2 = definitionList.RemoveDefinition(conn3unused);
     Assert.That(remove2, Is.EqualTo(false));
     Assert.That(definitionList.Definitions.Length, Is.EqualTo(1));
 }
Exemplo n.º 6
0
 /// <summary>
 ///     Removes the definition from the list.
 /// </summary>
 /// <param name = "connectionDefinition">The connection definition.</param>
 /// <returns>True if the item was removed.</returns>
 public bool RemoveDefinition(DbConnectionDefinition connectionDefinition)
 {
     return(_definitions.Remove(connectionDefinition));
 }
Exemplo n.º 7
0
 /// <summary>
 ///     Adds the definition from the list.
 /// </summary>
 /// <param name = "connectionDefinition">The connection definition.</param>
 public void AddDefinition(DbConnectionDefinition connectionDefinition)
 {
     _definitions.Add(connectionDefinition);
 }
        /// <summary>The write values back.</summary>
        protected void WriteValuesBack()
        {
            if (ConnectionDefinition == null)
            {
                ConnectionDefinition = new DbConnectionDefinition();
            }

            ConnectionDefinition.Name = ConnectionName;
            ConnectionDefinition.ProviderName = ProviderName;
            ConnectionDefinition.ConnectionString = ConnectionString;
            ConnectionDefinition.Comment = Comments;
            _dirty = false;
        }
 /// <summary>The update details panel.</summary>
 /// <param name="definition">The definition.</param>
 private void UpdateDetailsPanel(DbConnectionDefinition definition)
 {
     if (definition != null)
     {
         txtName.Text = definition.Name;
         txtProvider.Text = definition.ProviderName;
         txtConn.Text = definition.ConnectionString;
         txtComment.Text = definition.Comment;
     }
     else
     {
         txtName.Clear();
         txtProvider.Clear();
         txtConn.Clear();
         txtComment.Clear();
     }
 }
 /// <summary>The remove from list.</summary>
 /// <param name="definition">The definition.</param>
 private void RemoveFromList(DbConnectionDefinition definition)
 {
     if (lstConnections.Items.Contains(definition))
     {
         lstConnections.Items.Remove(definition);
     }
 }
        /// <summary>The manage definition.</summary>
        /// <param name="definition">The definition.</param>
        private void ManageDefinition(DbConnectionDefinition definition)
        {
            ConnectionStringBuilderForm frm;
            string oldName = null;

            if (definition == null)
            {
                frm = new ConnectionStringBuilderForm(_hostWindow, _services); // new blank form
            }
            else
            {
                oldName = definition.Name;
                frm = new ConnectionStringBuilderForm(_hostWindow, definition, _services);
            }

            frm.ShowDialog(this);

            if (frm.DialogResult == DialogResult.OK)
            {
                if (lstConnections.Items.Contains(frm.ConnectionDefinition) && definition != null)
                {
                    if (definition.Name != oldName)
                    {
                        // want the list text to update due to name change
                        UpdateListView();
                        lstConnections.SelectedItem = definition;
                    }
                    else
                    {
                        UpdateDetailsPanel(lstConnections.SelectedItem as DbConnectionDefinition);
                    }
                }
                else
                {
                    _definitionList.AddDefinition(frm.ConnectionDefinition);
                    AddToList(frm.ConnectionDefinition);
                    lstConnections.SelectedItem = frm.ConnectionDefinition;
                }
            }
        }
 /// <summary>
 /// 	Adds the definition from the list.
 /// </summary>
 /// <param name = "connectionDefinition">The connection definition.</param>
 public void AddDefinition(DbConnectionDefinition connectionDefinition)
 {
     _definitions.Add(connectionDefinition);
 }
 /// <summary>
 /// 	Removes the definition from the list.
 /// </summary>
 /// <param name = "connectionDefinition">The connection definition.</param>
 /// <returns>True if the item was removed.</returns>
 public bool RemoveDefinition(DbConnectionDefinition connectionDefinition)
 {
     return _definitions.Remove(connectionDefinition);
 }