private static void GenerateXmlCode(string path, List <FontDescriptor> fontDescriptors) { TextWriter writer; ICodeGenerator generator = new XmlCodeGenerator(); foreach (FontDescriptor fontDescriptor in fontDescriptors) { string fileName = Path.Combine(path, fontDescriptor.FontIdString) + ".xfont"; writer = new StreamWriter(fileName); try { generator.GenerateFontSource(writer, fontDescriptor); } finally { writer.Close(); } } }
public void CanRenderCode() { Dictionary <string, IInlineInstruction> inlines = new Dictionary <string, IInlineInstruction>(); inlines.Add("foreach", new ForEachInstruction()); inlines.Add("if", new IfInstruction()); inlines.Add("elseif", new ElseIfInstruction()); inlines.Add("else", new ElseInstruction()); inlines.Add("end", new EndInstruction()); Dictionary <string, ITypeInstruction> typeInst = new Dictionary <string, ITypeInstruction>(); typeInst.Add("template", new TemplateInstruction()); typeInst.Add("using", new UsingInstruction()); XmlReader reader = XmlReader.Create( new StringReader(@"<?xml version='1.0' standalone='yes' ?> <?template namespace=""foo"" classname=""bar"" ?> <?using namespace='System.IO' ?> <Element Id='Foo&Bar'> {System.DateTime.Now} <?if (foo) ?> <Root /> <?end?> <?foreach (object o in ""hello"") ?> <Bar/> <?end?> </Element>" )); XmlCodeGenerator renderer = new XmlCodeGenerator( typeInst, inlines, "Foo", "Bar" ); CodeNamespace ns = renderer.GenerateCode(reader); RenderStatements(ns); Console.WriteLine(); }
public void CanRenderCode() { Dictionary<string, IInlineInstruction> inlines = new Dictionary<string, IInlineInstruction>(); inlines.Add("foreach", new ForEachInstruction()); inlines.Add("if", new IfInstruction()); inlines.Add("elseif", new ElseIfInstruction()); inlines.Add("else", new ElseInstruction()); inlines.Add("end", new EndInstruction()); Dictionary<string, ITypeInstruction> typeInst = new Dictionary<string, ITypeInstruction>(); typeInst.Add("template", new TemplateInstruction()); typeInst.Add("using", new UsingInstruction()); XmlReader reader = XmlReader.Create( new StringReader(@"<?xml version='1.0' standalone='yes' ?> <?template namespace=""foo"" classname=""bar"" ?> <?using namespace='System.IO' ?> <Element Id='Foo&Bar'> {System.DateTime.Now} <?if (foo) ?> <Root /> <?end?> <?foreach (object o in ""hello"") ?> <Bar/> <?end?> </Element>")); XmlCodeGenerator renderer = new XmlCodeGenerator( typeInst, inlines, "Foo", "Bar" ); CodeNamespace ns = renderer.GenerateCode(reader); RenderStatements(ns); Console.WriteLine(); }