示例#1
0
 /// <summary>
 /// Remove a registered default repository
 /// </summary>
 /// <param name="repository"></param>
 public static void UnregisterDefaultRepository(this IPackageRepository repository)
 {
     if (DefaultRepositories.ContainsKey(repository.Url))
     {
         DefaultRepositories.Remove(repository.Url);
     }
 }
示例#2
0
        /// <summary>
        /// Tries to get or create a <see cref="IPackageRepository"/> instance for a reference
        /// </summary>
        /// <param name="reference"></param>
        /// <param name="repo">The output repository</param>
        /// <returns>True if getting a repository was successful</returns>
        public static bool TryGetRepository(this PartialPackageReference reference, out IPackageRepository repo)
        {
            repo = null;
            if (reference == null)
            {
                return(false);
            }
            if (!string.IsNullOrWhiteSpace(reference.RepositoryUrl))
            {
                var res = DefaultRepositories.TryGetValue(reference.RepositoryUrl, out repo);
                if (!res)
                {
                    res = PresentRepositories.TryGetValue(reference.RepositoryUrl, out repo);
                }
                if (!res && TryCreateRepository(reference.RepositoryUrl, out repo))
                {
                    repo.RegisterRepository();
                    res = repo.Refresh();
                }

                if (res)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Logging.L.Verbose("Repository of {$PackRef} is not specified, looking for it in default repositories", reference);
                foreach (var defrepo in DefaultRepositories.Values)
                {
                    if (defrepo.TryGetPackageText(reference, out _))
                    {
                        repo = defrepo;
                        return(true);
                    }
                }
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// Register this repository as a default one, which will be used to infer
 /// package references without reference to specific repository.
 /// </summary>
 /// <remarks>
 /// Default repositories must be specified and completely initialized by the
 /// implementer of uppm.Core before any other uppm operations take place.
 /// </remarks>
 public static void RegisterDefaultRepository(this IPackageRepository repository)
 {
     DefaultRepositories.UpdateGeneric(repository.Url, repository);
     PresentRepositories.UpdateGeneric(repository.Url, repository);
 }