public override string CreateContent (Project project, Dictionary<string, string> tags, string language) { if (language == null || language == "") throw new InvalidOperationException ("Language not defined in CodeDom based template."); var binding = GetLanguageBinding (language); CodeDomProvider provider = null; if (binding != null) provider = binding.GetCodeDomProvider (); if (provider == null) throw new InvalidOperationException ("The language '" + language + "' does not have support for CodeDom."); var xcd = new XmlCodeDomReader (); var cu = xcd.ReadCompileUnit (domContent); foreach (CodeNamespace cns in cu.Namespaces) cns.Name = StripImplicitNamespace (project, tags, cns.Name); CodeGeneratorOptions options = new CodeGeneratorOptions (); options.IndentString = "\t"; options.BracingStyle = "C"; StringWriter sw = new StringWriter (); provider.GenerateCodeFromCompileUnit (cu, sw, options); sw.Close (); return StripHeaderAndBlankLines (sw.ToString (), provider); }
public override string CreateContent(Project project, Dictionary <string, string> tags, string language) { if (language == null || language == "") { throw new InvalidOperationException("Language not defined in CodeDom based template."); } IDotNetLanguageBinding binding = GetLanguageBinding(language) as IDotNetLanguageBinding; CodeDomProvider provider = null; if (binding != null) { provider = binding.GetCodeDomProvider(); } if (provider == null) { throw new InvalidOperationException("The language '" + language + "' does not have support for CodeDom."); } var xcd = new XmlCodeDomReader(); var cu = xcd.ReadCompileUnit(domContent); foreach (CodeNamespace cns in cu.Namespaces) { cns.Name = StripImplicitNamespace(project, tags, cns.Name); } CodeGeneratorOptions options = new CodeGeneratorOptions(); options.IndentString = "\t"; options.BracingStyle = "C"; StringWriter sw = new StringWriter(); provider.GenerateCodeFromCompileUnit(cu, sw, options); sw.Close(); return(StripHeaderAndBlankLines(sw.ToString(), provider)); }