コード例 #1
0
ファイル: PageWriter.cs プロジェクト: wsky/docu
        public void CreatePages(string templateDirectory, string destination, IList <Namespace> namespaces)
        {
            var paths = patternTemplateResolver.Resolve(templateDirectory, namespaces);

            foreach (var path in paths)
            {
                var outputDir  = Path.GetDirectoryName(path.OutputPath);
                var outputPath = path.OutputPath;

                if (!string.IsNullOrEmpty(destination))
                {
                    var outputFilename = Path.GetFileName(path.OutputPath);

                    if (!string.IsNullOrEmpty(templatePath))
                    {
                        outputDir = outputDir.Replace(templatePath, destination);
                    }
                    else
                    {
                        outputDir = Path.Combine(destination, outputDir);
                    }

                    outputPath = Path.Combine(outputDir, outputFilename);
                }

                var relativePath = outputPath.Replace(destination + "\\", "");
                var output       = generator.Convert(path.TemplatePath, path.Data, relativePath);

                if (outputDir != "" && !writer.Exists(outputDir))
                {
                    writer.CreateDirectory(outputDir);
                }

                writer.WriteFile(outputPath, output);
            }
        }