Ejemplo n.º 1
0
        /// <summary>
        /// Add a new dependency to the repository
        /// </summary>
        /// <param name="dependency">Dependency to add.</param>
        /// <param name="dependencyType">Type of dependency.</param>
        /// <param name="repoUri">Repository URI to add the dependency to.</param>
        /// <param name="branch">Branch to add the dependency to.</param>
        /// <returns>Async task.</returns>
        public async Task AddDependencyAsync(
            DependencyDetail dependency,
            DependencyType dependencyType,
            string repoUri,
            string branch)
        {
            if ((await ParseVersionDetailsXmlAsync(repoUri, branch)).Any(
                    existingDependency => existingDependency.Name.Equals(dependency.Name, StringComparison.OrdinalIgnoreCase)))
            {
                throw new DependencyException($"Dependency {dependency.Name} already exists in this repository");
            }

            if (DependencyOperations.TryGetKnownUpdater(dependency.Name, out Delegate function))
            {
                await(Task) function.DynamicInvoke(this, repoUri, branch, dependency);
            }
            else
            {
                await AddDependencyToVersionsPropsAsync(
                    repoUri,
                    branch,
                    dependency);
                await AddDependencyToVersionDetailsAsync(
                    repoUri,
                    branch,
                    dependency,
                    dependencyType);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a dependency to the dependency files
        /// </summary>
        /// <returns></returns>
        public async Task AddDependenciesAsync(DependencyDetail dependency, DependencyType dependencyType)
        {
            if (DependencyOperations.TryGetKnownUpdater(dependency.Name, out Delegate function))
            {
                await(Task) function.DynamicInvoke(_fileManager, _repo, dependency);
            }
            else
            {
                await _fileManager.AddDependencyToVersionProps(Path.Combine(_repo, VersionFilePath.VersionProps), dependency);

                await _fileManager.AddDependencyToVersionDetails(Path.Combine(_repo, VersionFilePath.VersionDetailsXml), dependency, dependencyType);
            }
        }