Beispiel #1
0
        public RepositoryInfo GetRepositoryFromGuid(Guid guid)
        {
            lock (this)
            {
                if (GuidToRepository.ContainsKey(guid))
                {
                    return(GuidToRepository[guid]);
                }
            }

            return(null);
        }
Beispiel #2
0
        protected void LoadRepositories()
        {
            lock (GuidToRepository)
            {
                GuidToRepository.Clear();

                foreach (RepositoryInfo nextRepo in Settings.GetRepositories())
                {
                    DirectoryInfo rootDirectory =
                        new DirectoryInfo(nextRepo.RepositoryPath);

                    GuidToRepository[nextRepo.Guid] =
                        new LocalRepositoryState(rootDirectory, false);
                }
            }
        }
Beispiel #3
0
        public void RemoveRepository(Guid guid)
        {
            lock (this)
            {
                if (GuidToRepository.ContainsKey(guid) == false)
                {
                    throw new Exception("Repository GUID is not registered.");
                }

                RepositoryInfo repoInfo = GuidToRepository[guid];
                GuidToRepository.Remove(guid);

                if (repoInfo.Name != null)
                {
                    NameToRepository.Remove(repoInfo.Name);
                }
            }
        }
Beispiel #4
0
        public void AddRepository(RepositoryInfo repoInfo)
        {
            lock (this)
            {
                if (GetRepositoryFromGuid(repoInfo.Guid) != null)
                {
                    throw new Exception("Repository GUID is already registered.");
                }

                if (repoInfo.Name != null &&
                    GetRepositoryFromName(repoInfo.Name) != null)
                {
                    throw new Exception("Repository name is already registered.");
                }

                GuidToRepository.Add(repoInfo.Guid, repoInfo);
                if (repoInfo.Name != null)
                {
                    NameToRepository[repoInfo.Name] = repoInfo;
                }
            }
        }