/// <summary> /// Executes the code generation workflow. /// </summary> public CodeWriterOutput GenerateCode(Options.CodeGenOptions options) { ICodeGeneratorContext codeGeneratorContext = buildCodeGeneratorContext(options); ICodeGenerator codeGenerator = this.buildCodeGenerator(options); CodeWriterOptions writeOptions = CodeGenOptionsParser.GetCodeWriterOptions(options); if (options.OnlyUseDataContractSerializer) { CodeCompileUnit targetCodeCompileUnit = codeGenerator.GenerateDataContractCode(codeGeneratorContext); return(CodeWriter.CodeWriter.Write(targetCodeCompileUnit, writeOptions)); } else if (options.GenerateSeparateFilesEachXsd) { CodeNamespace[] targetCodeNamespaces = codeGenerator.GenerateCodes(codeGeneratorContext); return(CodeWriter.CodeWriter.Write(targetCodeNamespaces, writeOptions)); } else { CodeNamespace targetCodeNamespace = codeGenerator.GenerateCode(codeGeneratorContext); return(CodeWriter.CodeWriter.Write(targetCodeNamespace, writeOptions)); } }