public static string CreateClassOutputFilePath(string objName, Type objType, ITemplate template, string outputFolder) { string fileName = objName ?? objType.Name; string nameSuffix = template.GetVariable(SpecialVariable.FileNameSuffix) ?? template.GetSetting(SpecialVariable.FileNameSuffix); string extension = template.GetSetting(SpecialVariable.FileExtension) ?? DefaultFileExtension; string subdir = GenUtil.GetOutputSubdirectoryVariable(template); string filePath; if (string.IsNullOrEmpty(subdir)) filePath = string.Format("{0}{1}{2}.{3}", outputFolder, fileName, nameSuffix, extension); else filePath = string.Format("{0}{1}\\{2}{3}.{4}", outputFolder, subdir, fileName, nameSuffix, extension); return filePath; }
private string GenerateSingleFileForTemplate(ITemplate template, object[] bizObjects) { string fileNameWithExt = template.GetVariable(SpecialVariable.SingleFile) ?? template.GetSetting(SpecialVariable.SingleFile); string filePath = GenUtil.CreateSingleFilePathForTemplate(template, this.outputFolder, fileNameWithExt); using (StreamWriter codeOutput = new StreamWriter(filePath, /*overwrite existing file*/ false, Encoding.UTF8)) { template.Run(codeOutput, bizObjects); } return fileNameWithExt; }
public static bool ShouldWriteToSingleFile(ITemplate template) { return !string.IsNullOrEmpty(template.GetVariable(SpecialVariable.SingleFile)) || !string.IsNullOrEmpty(template.GetSetting(SpecialVariable.SingleFile)); }