示例#1
0
        /// <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)
            {
                SetDirty();

                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;
                }
            }
        }
示例#2
0
        public void Can_add_DbConnectionDefinition_object()
        {
            DbConnectionDefinitionList definitionList = new DbConnectionDefinitionList();

            definitionList.DefaultName = "def";
            definitionList.Definitions = new[]
            {
                new DbConnectionDefinition {
                    ConnectionString = "cs1", Name = "nm1", ProviderName = "p1"
                },
                new DbConnectionDefinition {
                    ConnectionString = "cs2", Name = "nm2", ProviderName = "p2"
                }
            };
            Assert.That(definitionList.Definitions.Length, Is.EqualTo(2));
            definitionList.AddDefinition(new DbConnectionDefinition {
                ConnectionString = "cs3", Name = "nm3", ProviderName = "p3"
            });
            Assert.That(definitionList.Definitions.Length, Is.EqualTo(3));
        }