示例#1
0
        /// <summary>
        /// Generate the node set files and deploy the web content files
        /// </summary>
        /// <param name="settings"></param>
        public async Task <GraphRunner> DeployAsync(GraphSettings settings)
        {
            if (settings.Generator == null)
            {
                context.Log.Information("No generator set. Using mermaid generator");
                settings.WithMermaidGenerator();
            }

            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Writing files");
            context.Log.Write(Verbosity.Diagnostic, LogLevel.Information, $"Ensuring node sets directory at {settings.OutputPath}");

            if (!string.IsNullOrWhiteSpace(settings.OutputPath))
            {
                Directory.CreateDirectory(settings.OutputPath);
            }

            foreach (var task in tasks)
            {
                var value = await settings.Generator.SerializeAsync(context, task, tasks);

                var filePath = Path.Combine(settings.OutputPath, $"{task.Name}.{settings.Generator.Extension}");
                using (var file = File.CreateText(filePath))
                    file.Write(value);
            }

            return(this);
        }
示例#2
0
        /// <summary>
        /// Generate the node set files and deploy the web content files
        /// </summary>
        /// <param name="settings"></param>
        public GraphRunner Deploy(GraphSettings settings)
        {
            if (settings.Generator == null)
            {
                context.Log.Information("No generator set. Using mermaid generator");
                settings.WithMermaidGenerator();
            }

            var output =
                tasks.Select(
                    x => new KeyValuePair <string, string>(x.Name, settings.Generator.Serialize(context, x, tasks)));

            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Writing files");
            context.Log.Write(Verbosity.Diagnostic, LogLevel.Information, $"Ensuring node sets directory at {settings.OutputPath}");
            if (!string.IsNullOrWhiteSpace(settings.OutputPath))
            {
                Directory.CreateDirectory(settings.OutputPath);
            }

            foreach (var task in output)
            {
                var filePath = Path.Combine(settings.OutputPath, $"{task.Key}.{settings.Generator.Extension}");
                using (var file = File.CreateText(filePath))
                    file.Write(task.Value);
            }

            return(this);
        }