private static void Uml2Diagram(IEnumerable <string> paths, string target) { foreach (string path in paths) { Console.WriteLine(path); string graphdir = target.Length > 0 ? target + "/" : path + "/graphs/"; List <IUmlObject> allObjects = new List <IUmlObject> (); Action <string> processFile = (filename) => { if (!filename.Contains("graphs") && !filename.Contains("ModelDefinition")) { IParser parser = new UmlParser(); Console.WriteLine("Read: " + filename); allObjects.AddRange(parser.Parse(filename)); //foreach (IUmlObject obj in objects) { // Console.WriteLine (obj); //} } }; Files.SearchFiles(path, new string[] { ".uml" }, processFile); Console.WriteLine("Write: " + "classes.dot"); ClassDiagram allDia = new ClassDiagram(allObjects); Files.WriteLines(graphdir + "classes.dot", allDia.DotCode()); GraphViz.Dot("svg", graphdir + "classes.dot", graphdir + "classes.svg"); GraphViz.Dot("png", graphdir + "classes.dot", graphdir + "classes.png"); foreach (UmlClass obj in allObjects.OfType <UmlClass>()) { string filename = "class-" + obj.Name.Clean(); Console.WriteLine("Write: " + filename + ".svg"); IEnumerable <IUmlObject> relatedObjects = obj.FindRelated(allObjects); // write class diagram ClassDiagram dia = new ClassDiagram(relatedObjects); Files.WriteLines(graphdir + filename + ".dot", dia.DotCode()); GraphViz.Dot("svg", graphdir + filename + ".dot", graphdir + filename + ".svg"); // write uml code List <string> lines = new List <string> (); foreach (IUmlObject relObj in relatedObjects) { lines.Add(relObj.ToUmlCode() + "\n"); } Files.WriteLines(graphdir + filename + ".uml", lines); } } }
private static void Uml2Code(IEnumerable <string> paths, string _target) { foreach (string path in paths) { string target = _target.Length > 0 ? _target + "/" : path + "/codegen/"; Console.WriteLine(path); List <IUmlObject> objects = new List <IUmlObject> (); Action <string> processFile = (filename) => { IParser parser = new UmlParser(); objects.AddRange(parser.Parse(filename)); }; Files.SearchFiles(path, new string[] { ".uml" }, processFile); foreach (IUmlObject obj in objects) { List <string> lines = new List <string> (); lines.Add(obj.ToCSharpCode() + "\n"); string genfile = target + Packages.GetPackage(obj.Name).Replace(".", "/") + "/" + obj.Name.Clean() + ".cs"; Console.WriteLine("Write: " + genfile); Files.WriteLines(genfile, lines); } } }
private static void Uml2Tex(IEnumerable<string> umlfiles, string target) { List<IUmlObject> allObjects = new List<IUmlObject> (); foreach (string umlfile in umlfiles) { IParser parser = new UmlParser (); Console.WriteLine ("Read: " + umlfile); allObjects.AddRange (parser.Parse (umlfile)); } Console.WriteLine ("Write: " + target); List<string> lines = new List<string> (); lines.AddRange (UmlObject.TexHeader); foreach (string package in Packages.PackageMap.Keys) { lines.Add (@"\section{Paket " + package + @"}"); lines.Add (@"\subsection{Klassen}"); foreach (UmlClass obj in allObjects.OfType<UmlClass>().Where((c) => Packages.IsInPackage(package, c.Name))) { if (obj.type != ClassType.Interface) { lines.Add (obj.ToTexCode ()); lines.Add (""); } } lines.Add (@"\subsection{Schnittstellen}"); foreach (UmlClass obj in allObjects.OfType<UmlClass>().Where((c) => Packages.IsInPackage(package, c.Name))) { if (obj.type == ClassType.Interface) { lines.Add (obj.ToTexCode ()); lines.Add (""); } } lines.Add (@"\subsection{Enumerationen}"); foreach (UmlEnum obj in allObjects.OfType<UmlEnum>().Where((c) => Packages.IsInPackage(package, c.Name))) { lines.Add (obj.ToTexCode ()); lines.Add (""); } } Files.WriteLines (target, lines); lines.Clear (); newCommand (ref lines, "CountClasses", "" + allObjects.OfType<UmlClass> () .Where ((o) => o.type == ClassType.Class).Count () ); newCommand (ref lines, "CountInterfaces", "" + allObjects.OfType<UmlClass> () .Where ((o) => o.type == ClassType.Interface).Count () ); newCommand (ref lines, "CountEnums", "" + allObjects.OfType<UmlEnum> () .Count () ); newCommand (ref lines, "CountAll", "" + (allObjects.OfType<UmlClass> () .Where ((o) => o.type == ClassType.Class).Count () + allObjects.OfType<UmlClass> () .Where ((o) => o.type == ClassType.Interface).Count () + allObjects.OfType<UmlEnum> () /* Strukturen? */ .Count ()) ); Files.WriteLines (Path.GetDirectoryName (target) + "/Definitionen.gentex", lines); if (IsRunningOnMono ()) { foreach (UmlClass obj in allObjects.OfType<UmlClass>()) { // write class diagram ClassDiagram dia = new ClassDiagram (new IUmlObject[] { obj }); string filename = Path.GetDirectoryName (target) + "/Klassen/" + obj.Name.Clean (); Files.WriteLines (filename + ".dot", dia.DotCode ("", "ffffff", 200)); //GraphViz.Dot ("svg", filename + ".dot", filename + ".svg"); //GraphViz.Dot ("jpg", filename + ".dot", filename + ".jpg"); //GraphViz.Dot ("png", filename + ".dot", filename + ".png"); GraphViz.Dot ("svg", filename + ".dot", filename + ".svg"); //GraphViz.Convert ("-density 100", "svg:" + filename + ".svg", filename + ".png"); //GraphViz.RsvgConvert ("--dpi-x 120", "--dpi-y 120", filename + ".svg", ">", filename + ".png"); GraphViz.InkScape ("--export-png=" + filename + ".png", "--export-dpi=150", filename + ".svg"); } } }
private static void Uml2Diagram(IEnumerable<string> paths, string target) { foreach (string path in paths) { Console.WriteLine (path); string graphdir = target.Length > 0 ? target + "/" : path + "/graphs/"; List<IUmlObject> allObjects = new List<IUmlObject> (); Action<string> processFile = (filename) => { if (!filename.Contains ("graphs") && !filename.Contains ("ModelDefinition")) { IParser parser = new UmlParser (); Console.WriteLine ("Read: " + filename); allObjects.AddRange (parser.Parse (filename)); //foreach (IUmlObject obj in objects) { // Console.WriteLine (obj); //} } }; Files.SearchFiles (path, new string[]{".uml"}, processFile); Console.WriteLine ("Write: " + "classes.dot"); ClassDiagram allDia = new ClassDiagram (allObjects); Files.WriteLines (graphdir + "classes.dot", allDia.DotCode ()); GraphViz.Dot ("svg", graphdir + "classes.dot", graphdir + "classes.svg"); GraphViz.Dot ("png", graphdir + "classes.dot", graphdir + "classes.png"); foreach (UmlClass obj in allObjects.OfType<UmlClass>()) { string filename = "class-" + obj.Name.Clean (); Console.WriteLine ("Write: " + filename + ".svg"); IEnumerable<IUmlObject> relatedObjects = obj.FindRelated (allObjects); // write class diagram ClassDiagram dia = new ClassDiagram (relatedObjects); Files.WriteLines (graphdir + filename + ".dot", dia.DotCode ()); GraphViz.Dot ("svg", graphdir + filename + ".dot", graphdir + filename + ".svg"); // write uml code List<string> lines = new List<string> (); foreach (IUmlObject relObj in relatedObjects) { lines.Add (relObj.ToUmlCode () + "\n"); } Files.WriteLines (graphdir + filename + ".uml", lines); } } }
private static void Uml2Code(IEnumerable<string> paths, string _target) { foreach (string path in paths) { string target = _target.Length > 0 ? _target + "/" : path + "/codegen/"; Console.WriteLine (path); List<IUmlObject> objects = new List<IUmlObject> (); Action<string> processFile = (filename) => { IParser parser = new UmlParser (); objects.AddRange (parser.Parse (filename)); }; Files.SearchFiles (path, new string[]{".uml"}, processFile); foreach (IUmlObject obj in objects) { List<string> lines = new List<string> (); lines.Add (obj.ToCSharpCode () + "\n"); string genfile = target + Packages.GetPackage (obj.Name).Replace (".", "/") + "/" + obj.Name.Clean () + ".cs"; Console.WriteLine ("Write: " + genfile); Files.WriteLines (genfile, lines); } } }
private static void Uml2Tex(IEnumerable <string> umlfiles, string target) { List <IUmlObject> allObjects = new List <IUmlObject> (); foreach (string umlfile in umlfiles) { IParser parser = new UmlParser(); Console.WriteLine("Read: " + umlfile); allObjects.AddRange(parser.Parse(umlfile)); } Console.WriteLine("Write: " + target); List <string> lines = new List <string> (); lines.AddRange(UmlObject.TexHeader); foreach (string package in Packages.PackageMap.Keys) { lines.Add(@"\section{Paket " + package + @"}"); lines.Add(@"\subsection{Klassen}"); foreach (UmlClass obj in allObjects.OfType <UmlClass>().Where((c) => Packages.IsInPackage(package, c.Name))) { if (obj.type != ClassType.Interface) { lines.Add(obj.ToTexCode()); lines.Add(""); } } lines.Add(@"\subsection{Schnittstellen}"); foreach (UmlClass obj in allObjects.OfType <UmlClass>().Where((c) => Packages.IsInPackage(package, c.Name))) { if (obj.type == ClassType.Interface) { lines.Add(obj.ToTexCode()); lines.Add(""); } } lines.Add(@"\subsection{Enumerationen}"); foreach (UmlEnum obj in allObjects.OfType <UmlEnum>().Where((c) => Packages.IsInPackage(package, c.Name))) { lines.Add(obj.ToTexCode()); lines.Add(""); } } Files.WriteLines(target, lines); lines.Clear(); newCommand(ref lines, "CountClasses", "" + allObjects.OfType <UmlClass> () .Where((o) => o.type == ClassType.Class).Count() ); newCommand(ref lines, "CountInterfaces", "" + allObjects.OfType <UmlClass> () .Where((o) => o.type == ClassType.Interface).Count() ); newCommand(ref lines, "CountEnums", "" + allObjects.OfType <UmlEnum> () .Count() ); newCommand(ref lines, "CountAll", "" + (allObjects.OfType <UmlClass> () .Where((o) => o.type == ClassType.Class).Count() + allObjects.OfType <UmlClass> () .Where((o) => o.type == ClassType.Interface).Count() + allObjects.OfType <UmlEnum> () /* Strukturen? */ .Count()) ); Files.WriteLines(Path.GetDirectoryName(target) + "/Definitionen.gentex", lines); if (IsRunningOnMono()) { foreach (UmlClass obj in allObjects.OfType <UmlClass>()) { // write class diagram ClassDiagram dia = new ClassDiagram(new IUmlObject[] { obj }); string filename = Path.GetDirectoryName(target) + "/Klassen/" + obj.Name.Clean(); Files.WriteLines(filename + ".dot", dia.DotCode("", "ffffff", 200)); //GraphViz.Dot ("svg", filename + ".dot", filename + ".svg"); //GraphViz.Dot ("jpg", filename + ".dot", filename + ".jpg"); //GraphViz.Dot ("png", filename + ".dot", filename + ".png"); GraphViz.Dot("svg", filename + ".dot", filename + ".svg"); //GraphViz.Convert ("-density 100", "svg:" + filename + ".svg", filename + ".png"); //GraphViz.RsvgConvert ("--dpi-x 120", "--dpi-y 120", filename + ".svg", ">", filename + ".png"); GraphViz.InkScape("--export-png=" + filename + ".png", "--export-dpi=150", filename + ".svg"); } } }