/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> private static void Main(string[] args) { var options = new Options(); if (!Parser.Default.ParseArguments(args, options)) { return; } var xml = File.ReadAllText(options.XmlFile); var classInfo = new Xml2CSharpConverer().Convert(xml); var classInfoWriter = new ClassInfoWriter(classInfo, options.CustomNameSpace); if (string.IsNullOrEmpty(options.CSharpFileName)) { classInfoWriter.WriteHeader(Console.Out); classInfoWriter.Write(Console.Out); classInfoWriter.WriteFooter(Console.Out); } if (!string.IsNullOrEmpty(options.CSharpFileName)) { using (var sw = new StreamWriter(File.OpenWrite(options.CSharpFileName))) { classInfoWriter.WriteHeader(sw); classInfoWriter.Write(sw); classInfoWriter.WriteFooter(sw); } } }
static void Main(string[] args) { var options = new Options(); if (!Parser.Default.ParseArguments(args, options)) return; var xml = File.ReadAllText(options.XmlFile); var classInfo = new Xml2CSharpConverer().Convert(xml); var classInfoWriter = new ClassInfoWriter(classInfo); classInfoWriter.Write(Console.Out); classInfoWriter.Write(new StreamWriter(File.OpenWrite(options.CSharpFileName))); }
public When_writing() { var classInfo = new[] { new Class { Name = "MyClass", XmlName = "MyClass", Namespace = "", Fields = new[] { new Field { Name = "Age", Type = "String", XmlType = XmlType.Element, XmlName = "Age2", Namespace = "wibble" }, new Field { Name = "Name", Type = "String", XmlName = "Name", XmlType = XmlType.Attribute }, } } }; var writer = new ClassInfoWriter(classInfo); stringWriter = new InMemoryTextWriter(); writer.Write(stringWriter); }
public void Then_no_duplicate_classes_are_created(string fileName) { var classInfo = new Xml2CSharpConverer().Convert(File.ReadAllText(Path.Combine("Specs\\ConvertExamples", fileName))); var writer = new ClassInfoWriter(classInfo); writer.Write(Console.Out); classInfo.Select(c => c.Name).Distinct().Should().HaveCount(classInfo.Count()); }
public void Then_no_duplicate_classes_are_created(string fileName) { var classInfo = new Xml2CSharpConverer().Convert(File.ReadAllText(Path.Combine("Specs\\ConvertExamples", fileName))); var writer = new ClassInfoWriter(classInfo); writer.Write(Console.Out); classInfo.Select(c => c.Name).Distinct().Should().HaveCount(classInfo.Count()); }
static void Main(string[] args) { var options = new Options(); if (!Parser.Default.ParseArguments(args, options)) { return; } var xml = File.ReadAllText(options.XmlFile); var classInfo = new Xml2CSharpConverer().Convert(xml); var classInfoWriter = new ClassInfoWriter(classInfo); classInfoWriter.Write(Console.Out); classInfoWriter.Write(new StreamWriter(File.OpenWrite(options.CSharpFileName))); }
public Home() { Get["/"] = parameters => { return View["Index"]; }; Post["/"] = parameters => { var xml = this.Request.Form.xml; var classInfo = new Xml2CSharpConverer().Convert(xml); var classInfoWriter = new ClassInfoWriter(classInfo); var stringWriter = new StringWriter(); classInfoWriter.Write(stringWriter); return View["result", new ConvertResponse { CSharpCode = stringWriter.ToString() }]; }; }
public Home() { Get["/"] = parameters => { return(View["Index"]); }; Post["/"] = parameters => { var xml = this.Request.Form.xml; var classInfo = new Xml2CSharpConverer().Convert(xml); var classInfoWriter = new ClassInfoWriter(classInfo); var stringWriter = new StringWriter(); classInfoWriter.Write(stringWriter); return(View["result", new ConvertResponse { XmlInput = xml, CSharpCode = stringWriter.ToString() }]); }; }
public Home() { Get["/"] = parameters => { return(View["Index"]); }; Post["/"] = parameters => { var xml = this.Request.Form.xml; var classInfo = new Xml2CSharpConverer().Convert(xml); var classInfoWriter = new ClassInfoWriter(classInfo); var stringWriter = new StringWriter(); classInfoWriter.Write(stringWriter); File.WriteAllText(@"E:\_MIS_Moalemi\final.cs", stringWriter.ToString()); return(View["result", new ConvertResponse { CSharpCode = stringWriter.ToString() }]); }; }
public When_writing() { var classInfo = new[] { new Class { Name = "MyClass", XmlName = "MyClass", Namespace = "", Fields = new[] { new Field { Name = "Age", Type = "String", XmlType = XmlType.Element, XmlName = "Age2", Namespace = "wibble" }, new Field { Name = "Name", Type = "String", XmlName = "Name", XmlType = XmlType.Attribute }, } } }; var writer = new ClassInfoWriter(classInfo); stringWriter = new InMemoryTextWriter(); writer.Write(stringWriter); }