示例#1
0
        /// <summary>
        /// Checks the dependencies.
        /// </summary>
        /// <param name="dependencies">The parsed dependencies.</param>
        /// <returns>Returns a task that represents the asynchronous operation.</returns>
        /// <exception cref="NAME.Core.Exceptions.DependenciesCheckException">Thrown when any of the dependencies checks do not pass.</exception>
        public static async Task CheckDependencies(this ParsedDependencies dependencies)
        {
            var dependenciesStatuses = await GetDependenciesStatutes(dependencies).ConfigureAwait(false);

            if (dependenciesStatuses.Any(d => d.CheckPassed == false))
                throw new DependenciesCheckException(dependenciesStatuses);
        }
示例#2
0
        /// <summary>
        /// Checks the dependencies.
        /// </summary>
        /// <param name="dependencies">The parsed dependencies.</param>
        /// <returns>Returns a task that represents the asynchronous operation.</returns>
        /// <exception cref="NAME.Core.Exceptions.DependenciesCheckException">Thrown when any of the dependencies checks do not pass.</exception>
        public static async Task CheckDependencies(this ParsedDependencies dependencies)
        {
            var dependenciesStatuses = await GetDependenciesStatutes(dependencies).ConfigureAwait(false);

            if (dependenciesStatuses.Any(d => d.CheckStatus != NAMEStatusLevel.Ok))
            {
                throw new DependenciesCheckException(dependenciesStatuses);
            }
        }
示例#3
0
        /// <summary>
        /// Generates a json representation of the manifest;
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="version">The version.</param>
        /// <param name="dependencies">The dependencies.</param>
        /// <returns>Returns a task representing the asynchronous operation. The result contains the generated json manifest.</returns>
        public static async Task <string> GenerateJson(string name, string version, ParsedDependencies dependencies)
        {
            JsonClass rootJson = new JsonClass();

            rootJson.Add("nameVersion", Constants.NAME_ASSEMBLY_VERSION);
            rootJson.Add("name", name);

            if (version.Count(c => c == '.') > 2)
            {
                version = string.Join(".", version.Split('.').Take(3));
            }

            rootJson.Add("version", version);

            List <Task <JsonNode> > infrastructureTasks = new List <Task <JsonNode> >();

            foreach (var dependency in dependencies.InfrastructureDependencies)
            {
                infrastructureTasks.Add(dependency.ToJson());
            }
            List <Task <JsonNode> > serviceTasks = new List <Task <JsonNode> >();

            foreach (var dependency in dependencies.ServiceDependencies)
            {
                serviceTasks.Add(dependency.ToJson());
            }
            await Task.WhenAll(Task.WhenAll(serviceTasks), Task.WhenAll(infrastructureTasks)).ConfigureAwait(false);

            JsonArray infrastructureDependencies = new JsonArray();
            JsonArray serviceDependencies        = new JsonArray();

            foreach (var task in serviceTasks)
            {
                serviceDependencies.Add(task.Result);
            }
            foreach (var task in infrastructureTasks)
            {
                infrastructureDependencies.Add(task.Result);
            }
            rootJson.Add("infrastructure_dependencies", infrastructureDependencies);
            rootJson.Add("service_dependencies", serviceDependencies);

            return(rootJson.ToString());
        }
示例#4
0
        /// <summary>
        /// Gets the dependencies statutes.
        /// </summary>
        /// <param name="dependencies">The parsed dependencies.</param>
        /// <returns>Returns a task that represents the asynchrnous operationg. The result contains an enumerable with all the dependencies checks statuses.</returns>
        public static async Task<IEnumerable<DependencyCheckStatus>> GetDependenciesStatutes(this ParsedDependencies dependencies)
        {
            List<DependencyCheckStatus> dependenciesStatuses = new List<DependencyCheckStatus>();

            dependenciesStatuses.AddRange(await GetDependenciesStatutes(dependencies.ServiceDependencies).ConfigureAwait(false));
            dependenciesStatuses.AddRange(await GetDependenciesStatutes(dependencies.InfrastructureDependencies).ConfigureAwait(false));

            return dependenciesStatuses;
        }