public void Diagram(ElementProgram program) { List<CodeElement> codeElements = DataModel.BL.DataModel.rootCodeElements; string diagramSource = DiagramWriter(program); string applicationPath = "C:\\Users\\PROFIMEDICA\\Documents\\Visual Studio 2010\\WindowsFormsApplication1\\DiagramCreator\\DiagramFiles\\"; System.IO.StreamWriter file = new System.IO.StreamWriter(applicationPath + "diagram.gv"); file.AutoFlush = true; file.WriteLine("digraph n { splines=true; sep=\"+25,25\"; overlap=scalexy; nodesep=0.6; node [fontsize=11];"); file.WriteLine(diagramSource); file.WriteLine("}"); file.Close(); Diagram diagram = new Diagram("diagram"); string output = diagram.ExecuteDiagram(); if (string.IsNullOrEmpty(output)) { richTextBox1.Text = "Diagram Created Successfully!"; this.Close(); } else { richTextBox1.Text = output; } }
public void ToDiagram(ElementProgram program) { string diagramSource = CreateFromProgram(program); string applicationPath = "P:\\SYKYO\\DiagramCreator\\DiagramFiles\\"; System.IO.StreamWriter file = new System.IO.StreamWriter(applicationPath + "diagram.gv"); file.AutoFlush = true; file.WriteLine("digraph n { splines=true; sep=\"+25,25\"; overlap=scalexy; nodesep=0.6; node [fontsize=11];"); file.WriteLine(diagramSource); file.WriteLine("}"); file.Close(); Diagram diagram = new Diagram("diagram"); string output = diagram.ExecuteDiagram(); }
/// <summary> /// Constructor to initialize all lists /// </summary> public ModelReaderCS(string rootPath) { // Set root folder RootPath = rootPath; // Initialize lists FilePaths = new List<string>(); // Find all file paths GetFilePathList(); // Initialize base Element ElementProgram = new ElementProgram(); // Add all files to ElementProgram foreach (string filePath in FilePaths) { ExtractCodeNamespaces(filePath); } }
public EDocumentConvertor() { program = new ElementProgram(); program.programName = "AutogeneratedProgram"; }
private string CreateFromProgram(ElementProgram program) { StringBuilder sb = new StringBuilder(); string applicationPath = "P:\\SYKYO\\DiagramCreator\\DiagramFiles\\"; foreach (CodeFile codeFile in program.CodeFiles) { //using (StreamWriter sw = new StreamWriter(applicationRoot + "\\" + codeFile.FileName + ".cs", true)) using (StreamWriter sw = new StreamWriter(applicationPath + "\\" + "generated" + ".gw", true)) { foreach (ElementNamespace namespaceItem in codeFile.Namespaces) { sb.Append(" subgraph cluster_" + namespaceItem.ElementName + " { "); sb.Append(" style=filled; "); sb.Append(" color=lightgrey; "); sb.Append(" node [style=filled,color=white]; "); foreach (ElementClass classItem in namespaceItem.ElementClasses) { if (!classItem.Name.Equals("..")) { sb.Append(" " + classItem.Name + "; "); } } sb.Append(" label = \"" + namespaceItem.ElementName + "\"; "); sb.Append(" } "); foreach (ElementClass classItem in namespaceItem.ElementClasses) { /* foreach (ElementProperty codeProperty in classItem.ElementProperties) { if (!codeProperty.ElementName.Equals("..P")) sw.WriteLine(codeProperty.ToBlock()); } foreach (ElementMethod codeMethod in classItem.ElementMethods) { if (!codeMethod.ElementName.Equals("..")) if (!codeMethod.IsStatic) sw.WriteLine(codeMethod.ToBlock()); } foreach (ElementProperty codeProperty in classItem.ElementProperties) { if (!codeProperty.ElementName.Equals("..P") && codeProperty.IsMandatory) sw.WriteLine(" public bool isNullable" + codeProperty.ElementName + "P = false;"); } foreach (ElementProperty codeProperty in classItem.ElementProperties) { if (!codeProperty.ElementName.Equals("..P") && codeProperty.IsMandatory) { sw.WriteLine(" if (" + codeProperty.ElementName.ToLower() + "P == null)"); sw.WriteLine(" {"); sw.WriteLine(" result = false;"); sw.WriteLine(" }"); } } foreach (ElementMethod codeMethod in classItem.ElementMethods) { if (codeMethod.ElementName.StartsWith("Increasedby")) { sw.WriteLine(codeMethod.ToBlock()); } else if (codeMethod.ElementName.StartsWith("DecreasedBy")) { sw.WriteLine(codeMethod.ToBlock()); } else if (codeMethod.ElementName.StartsWith("Increase")) { sw.WriteLine(codeMethod.ToBlock()); } else if (codeMethod.ElementName.StartsWith("Decrease")) { sw.WriteLine(codeMethod.ToBlock()); } } * */ } } } } return sb.ToString(); }
public void ToProgrammingLanguage(ElementProgram program) { ClearProject(); GenerateCode(program); //GeneratePersistency(); }
/// <summary> /// generate filesystem of the application /// </summary> private void GenerateCode(ElementProgram program) { foreach (CodeFile codeFile in program.CodeFiles) { //using (StreamWriter sw = new StreamWriter(applicationRoot + "\\" + codeFile.FileName + ".cs", true)) using (StreamWriter sw = new StreamWriter(applicationRoot + "\\" + codeFile.FileName + ".cs", true)) { foreach (ElementNamespace namespaceItem in codeFile.Namespaces) { foreach (ElementClass classItem in namespaceItem.ElementClasses) { // Write anthet sw.WriteLine("using System;"); sw.WriteLine("using System.Collections.Generic;"); sw.WriteLine("using System.Linq;"); sw.WriteLine("using System.Text;"); sw.WriteLine("using System.Collections.ObjectModel;"); sw.WriteLine("namespace Object.Model"); sw.WriteLine("{"); sw.WriteLine("public class " + classItem.Name + "List : ObservableCollection<" + classItem.Name + ">"); sw.WriteLine("{"); sw.WriteLine("public bool Add(object newItem)"); sw.WriteLine("{"); sw.WriteLine("base.Add(newItem as " + classItem.Name + ");"); sw.WriteLine("return true;"); sw.WriteLine("}"); sw.WriteLine(""); sw.WriteLine("public bool Remove(object unwantedItem)"); sw.WriteLine(" {"); sw.WriteLine(" base.Remove(unwantedItem as " + classItem.Name + ");"); sw.WriteLine(" return true;"); sw.WriteLine(" }"); sw.WriteLine(""); sw.WriteLine(" private static " + classItem.Name + "List instance;"); sw.WriteLine(""); sw.WriteLine(" public " + classItem.Name + "List(): base() "); sw.WriteLine(" {"); sw.WriteLine(""); sw.WriteLine(" }"); sw.WriteLine(""); sw.WriteLine(" public static " + classItem.Name + "List GetInstance()"); sw.WriteLine(" {"); sw.WriteLine(" lock (typeof(" + classItem.Name + "List))"); sw.WriteLine(" {"); sw.WriteLine(" if (instance == null)"); sw.WriteLine(" {"); sw.WriteLine(" instance = new " + classItem.Name + "List();"); sw.WriteLine(" }"); sw.WriteLine(" return instance;"); sw.WriteLine(" }"); sw.WriteLine(" }"); sw.WriteLine(" }"); sw.WriteLine(""); sw.WriteLine(" [Serializable]"); sw.WriteLine(" public class " + classItem.Name + ""); sw.WriteLine(" {"); foreach (ElementProperty codeProperty in classItem.ElementProperties) { if (!codeProperty.ElementName.Equals("..P")) sw.WriteLine(codeProperty.ToBlock()); } foreach (ElementMethod codeMethod in classItem.ElementMethods) { if (!codeMethod.ElementName.Equals("..")) if (!codeMethod.IsStatic) sw.WriteLine(codeMethod.ToBlock()); } sw.WriteLine(" private int id;"); sw.WriteLine(" public int ID"); sw.WriteLine(" {"); sw.WriteLine(" get { return id; }"); sw.WriteLine(" set { id = value; }"); sw.WriteLine(" }"); sw.WriteLine(" private string name;"); sw.WriteLine(" public string Name"); sw.WriteLine(" {"); sw.WriteLine(" get { return name; }"); sw.WriteLine(" set { name = value; }"); sw.WriteLine(" }"); sw.WriteLine(" private string description;"); sw.WriteLine(" public string Description"); sw.WriteLine(" {"); sw.WriteLine(" get { return description; }"); sw.WriteLine(" set { description = value; }"); sw.WriteLine(" }"); sw.WriteLine(" private string url;"); sw.WriteLine(" public string URL"); sw.WriteLine(" {"); sw.WriteLine(" get { return url; }"); sw.WriteLine(" set { url = value; }"); sw.WriteLine(" }"); sw.WriteLine(" }"); sw.WriteLine("}"); sw.WriteLine(""); sw.WriteLine("namespace Object.Meta"); sw.WriteLine("{"); sw.WriteLine(""); sw.WriteLine(" public class " + classItem.Name + "Metainformation"); sw.WriteLine(" {"); foreach (ElementProperty codeProperty in classItem.ElementProperties) { if (!codeProperty.ElementName.Equals("..P") && codeProperty.IsMandatory) sw.WriteLine(" public bool isNullable" + codeProperty.ElementName + "P = false;"); } sw.WriteLine(""); sw.WriteLine(" public bool IsValid()"); sw.WriteLine(" {"); sw.WriteLine(" bool result = true;"); foreach (ElementProperty codeProperty in classItem.ElementProperties) { if (!codeProperty.ElementName.Equals("..P") && codeProperty.IsMandatory) { sw.WriteLine(" if (" + codeProperty.ElementName.ToLower() + "P == null)"); sw.WriteLine(" {"); sw.WriteLine(" result = false;"); sw.WriteLine(" }"); } } sw.WriteLine(" return result;"); sw.WriteLine(" }"); sw.WriteLine(" }"); sw.WriteLine("}"); sw.WriteLine("namespace Object.Influence"); sw.WriteLine("{"); sw.WriteLine(""); sw.WriteLine(" public class " + classItem.Name + "Influence"); sw.WriteLine(" {"); foreach (ElementMethod codeMethod in classItem.ElementMethods) { if (codeMethod.ElementName.StartsWith("Increasedby")) { sw.WriteLine(codeMethod.ToBlock()); } else if (codeMethod.ElementName.StartsWith("DecreasedBy")) { sw.WriteLine(codeMethod.ToBlock()); } else if (codeMethod.ElementName.StartsWith("Increase")) { sw.WriteLine(codeMethod.ToBlock()); } else if (codeMethod.ElementName.StartsWith("Decrease")) { sw.WriteLine(codeMethod.ToBlock()); } } sw.WriteLine(" }"); sw.WriteLine("}"); } } } } }