public ConnectionDescriptionViewModel AddConnection(ConnectionDescription connection)
        {
            var vm = new ConnectionDescriptionViewModel(connection, this, _knownConnections, new SelectFileView(), _connectionParameterViewModelFactory);

            ConnectionViewModels.Add(vm);
            Source.Connections.Add(vm.Source);

            return(vm);
        }
        private void DeleteConnection(ConnectionDescriptionViewModel obj)
        {
            var pair = ConnectionGroupViewModels
                       .SelectMany(g => g.ConnectionViewModels.Select(c => new  { Group = g, Connection = c }))
                       .Where(anon => anon.Connection == obj)
                       .FirstOrDefault();

            if (pair == null)
            {
                return;
            }

            obj.Source.Profile = null;
            var isSelected = obj == SelectedObject;
            int index      = 0;

            if (isSelected)
            {
                index = pair.Group.ConnectionViewModels.IndexOf(obj);
            }

            pair.Group.RemoveConnection(pair.Connection);

            if (isSelected)
            {
                if (pair.Group.ConnectionViewModels.Count == index)
                {
                    index--;
                }
                if (index >= 0)
                {
                    SelectedObject = pair.Group.ConnectionViewModels[index];
                }
                else
                {
                    SelectedObject = pair.Group;
                }
            }
        }
 public void RemoveConnection(ConnectionDescriptionViewModel connectionViewModel)
 {
     ConnectionViewModels.Remove(connectionViewModel);
     Source.Connections.Remove(connectionViewModel.Source);
 }