ClearCachedRepository() public method

public ClearCachedRepository ( ) : void
return void
Exemplo n.º 1
0
        /// <summary>
        /// Removes an on-line repository subscription.
        /// </summary>
        /// <param name="url">
        /// URL of the repository.
        /// </param>
        public void RemoveRepository(string url)
        {
            RepositoryRecord rep = FindRepositoryRecord(url);

            if (rep == null)
            {
                return;                 // Nothing to do
            }
            foreach (RepositoryRecord rr in service.Configuration.Repositories)
            {
                if (rr == rep)
                {
                    continue;
                }
                Repository newRep = rr.GetCachedRepository();
                if (newRep == null)
                {
                    continue;
                }
                foreach (ReferenceRepositoryEntry re in newRep.Repositories)
                {
                    if (re.Url == url)
                    {
                        // The repository can't be removed because there is another
                        // repository depending on it. Just mark it as a reference.
                        rep.IsReference = true;
                        return;
                    }
                }
            }

            // There are no other repositories referencing this one, so we can safely delete

            Repository delRep = rep.GetCachedRepository();

            service.Configuration.Repositories.Remove(rep);
            rep.ClearCachedRepository();

            if (delRep != null)
            {
                foreach (ReferenceRepositoryEntry re in delRep.Repositories)
                {
                    RemoveRepository(new Uri(new Uri(url), re.Url).ToString());
                }
            }

            service.SaveConfiguration();
            repoList = null;
        }
        public void RemoveRepository(string url)
        {
            RepositoryRecord rep = FindRepositoryRecord(url);

            if (rep == null)
            {
                throw new InstallException("The repository at url '" + url + "' is not registered");
            }

            foreach (RepositoryRecord rr in service.Configuration.Repositories)
            {
                if (rr == rep)
                {
                    continue;
                }
                Repository newRep = rr.GetCachedRepository();
                if (newRep == null)
                {
                    continue;
                }
                foreach (ReferenceRepositoryEntry re in newRep.Repositories)
                {
                    if (re.Url == url)
                    {
                        rep.IsReference = true;
                        return;
                    }
                }
            }

            // There are no other repositories referencing this one, so we can safely delete

            Repository delRep = rep.GetCachedRepository();

            service.Configuration.Repositories.Remove(rep);
            rep.ClearCachedRepository();

            if (delRep != null)
            {
                foreach (ReferenceRepositoryEntry re in delRep.Repositories)
                {
                    RemoveRepository(new Uri(new Uri(url), re.Url).ToString());
                }
            }

            service.SaveConfiguration();
            repoList = null;
        }