Example #1
0
 //public static void AddRepositoryConfig(RepositoryConfigElement element) {
 //    // Open App.Config of executable inorder to insert or update the data
 //    System.Configuration.Configuration configExc =
 //      ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
 //    GitConfigurationSection sectoin = (GitConfigurationSection)configExc.GetSection("testConfig.repositoryList");
 //    sectoin.RepositoryList.Add(element);
 //    // Save the configuration file.
 //    configExc.Save(ConfigurationSaveMode.Full);
 //    // Force a reload of a changed section.
 //    ConfigurationManager.RefreshSection("testConfig.repositoryList");
 //    /*
 //     //check if the eNew is added
 //    config = (GitConfigurationSection)ConfigurationManager.GetSection("testConfig.repositoryList");
 //    Console.WriteLine("after insert action, "+config.RepositoryList.Count + " repository settings are found :");
 //    foreach (RepositoryConfigElement e in config.RepositoryList) {
 //        Console.WriteLine(e.Name + ";" + e.LocalPath + ";" + e.RemoteURL + ";" + e.UserName + ";" + e.Password);
 //    }
 //     */
 //}
 public static RepositoryConfigCollection AddRepositoryConfig(RepositoryConfigElement element)
 {
     // Open App.Config of executable inorder to insert or update the data
     System.Configuration.Configuration configExc =
       ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
     GitConfigurationSection sectoin = (GitConfigurationSection)configExc.GetSection("testConfig.repositoryList");
     sectoin.RepositoryList.Add(element);
     // Save the configuration file.
     configExc.Save(ConfigurationSaveMode.Full);
     // Force a reload of a changed section.
     ConfigurationManager.RefreshSection("testConfig.repositoryList");
     GitConfigurationSection config = (GitConfigurationSection)ConfigurationManager.GetSection("testConfig.repositoryList");
     return config.RepositoryList;
 }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRepository_Click(object sender, EventArgs e)
        {
            RepositoryConfigElement newRepo = new RepositoryConfigElement();
            newRepo.Name = txtRepoName.Text;
            //check if we are adding or cloning a repo
            if (txtRepoPath.Enabled)
            {
                this.UseWaitCursor = true;
                Repository.Clone(txtRepoPath.Text, txtLocalPath.Text);

                newRepo.LocalPath = txtLocalPath.Text;
                newRepo.RemoteURL = txtRepoPath.Text;
                mLocalRepositories = IO_Config.AddRepositoryConfig(newRepo);
                addRepositoryToView(newRepo.LocalPath, newRepo.Name);

                this.UseWaitCursor = false;
            }else{
                if (Repository.Discover(fbdAddRepository.SelectedPath) != null)
                {
                    //repository available here, import it
                    newRepo.LocalPath = txtRepoPath.Text;
                    mLocalRepositories = IO_Config.AddRepositoryConfig(newRepo);
                    addRepositoryToView(newRepo.LocalPath, newRepo.Name);
                }
                else
                {
                    //create new repository
                    try
                    {
                        //config.add repository
                        currentRepo = Repository.Init(txtRepoPath.Text);
                        newRepo.LocalPath = txtRepoPath.Text;
                        mLocalRepositories = IO_Config.AddRepositoryConfig(newRepo);
                        addRepositoryToView(newRepo.LocalPath, newRepo.Name);
                    }
                    catch (RepositoryNotFoundException rne)
                    {
                        MessageBox.Show(rne.Message);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                }
            }
            tcRepositories.SelectTab(tcRepositories.TabCount - 1);
            hideAddRepoPanel();
        }
 public void Add(RepositoryConfigElement element)
 {
     this.BaseAdd(element);
 }