Inheritance: GitCommands.Repository.RepositoryCategory
Exemplo n.º 1
0
 public static void DeserializeHistoryFromXml(string xml)
 {
     try
     {
         var serializer = new XmlSerializer(typeof (RepositoryHistory));
         using (var stringReader = new StringReader(xml))
         using (var xmlReader = new XmlTextReader(stringReader))
         {
             var obj = serializer.Deserialize(xmlReader) as RepositoryHistory;
             if (obj != null)
             {
                 RepositoryHistory = obj;
                 RepositoryHistory.SetIcon();
             }
         }
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
Exemplo n.º 2
0
        private static RepositoryHistory LoadRepositoryHistory()
        {
            int size = AppSettings.GetInt("history size", DefaultRepositoriesCount);
            object setting = AppSettings.GetString("history", null);
            if (setting == null)
            {
                return new RepositoryHistory(size);
            }

            RepositoryHistory repositoryHistory = DeserializeHistoryFromXml(setting.ToString());
            if (repositoryHistory == null)
                return new RepositoryHistory(size);

            repositoryHistory.MaxCount = size;
            AssignRepositoryHistoryFromCategories(repositoryHistory, null);

            // migration from old version (move URL history to _remoteRepositoryHistory)
            if (AppSettings.GetString("history remote", null) == null)
            {
                _remoteRepositoryHistory = new RepositoryHistory(size);
                foreach (Repository repo in repositoryHistory.Repositories)
                {
                    if (repo.IsRemote)
                    {
                        repo.Path = repo.Path.Replace('\\', '/');
                        _remoteRepositoryHistory.AddRepository(repo);
                    }
                }
                foreach (Repository repo in _remoteRepositoryHistory.Repositories)
                {
                    repositoryHistory.RemoveRepository(repo);
                }
            }

            return repositoryHistory;
        }
Exemplo n.º 3
0
 private static string SerializeHistoryIntoXml(RepositoryHistory history)
 {
     try
     {
         var sw = new StringWriter();
         var serializer = new XmlSerializer(typeof(RepositoryHistory));
         serializer.Serialize(sw, history);
         return sw.ToString();
     }
     catch
     {
         return null;
     }
 }
Exemplo n.º 4
0
        private static RepositoryHistory LoadRepositoryHistory()
        {
            var repositoryHistory = new RepositoryHistory();
            object setting = Settings.GetValue<string>("history", null);
            if (setting == null)
            {
                repositoryHistory = new RepositoryHistory();
                return repositoryHistory;
            }

            repositoryHistory = DeserializeHistoryFromXml(setting.ToString());
            if (repositoryHistory != null)
            {
                AssignRepositoryHistoryFromCategories(repositoryHistory, null);

                // migration from old version (move URL history to _remoteRepositoryHistory)
                if (Settings.GetValue<string>("history remote", null) == null)
                {
                    _remoteRepositoryHistory = new RepositoryHistory();
                    foreach (Repository repo in repositoryHistory.Repositories)
                    {
                        if (repo.IsRemote)
                        {
                            repo.Path = repo.Path.Replace('\\', '/');
                            _remoteRepositoryHistory.AddRepository(repo);
                        }
                    }
                    foreach (Repository repo in _remoteRepositoryHistory.Repositories)
                    {
                        repositoryHistory.RemoveRepository(repo);
                    }
                }
            }

            return repositoryHistory ?? new RepositoryHistory();
        }
Exemplo n.º 5
0
 private static void AssignRepositoryHistoryFromCategories(RepositoryHistory repositoryHistory, string path)
 {
     foreach (Repository repo in repositoryHistory.Repositories)
     {
         if (path == null || path.Equals(repo.Path, StringComparison.CurrentCultureIgnoreCase))
         {
             Repository catRepo = FindFirstCategoryRepository(repo.Path);
             if (catRepo != null)
                 repo.Assign(catRepo);
         }
     }
 }