public override string ToCSharpCode(int padding = 0) { string paddingStr = String.Concat(Enumerable.Repeat(" ", padding)); List <string> lines = new List <string> (); lines.AddRange(Packages.GetUsingStatements(Packages.GetPackage(name))); if (Packages.IsInPackage(name)) { lines.Add(paddingStr + "namespace " + Packages.GetPackage(name)); lines.Add(paddingStr + "{"); paddingStr += " "; padding += 4; } lines.AddRange(Comments.CSharpComments(commentsKey, paddingStr)); lines.Add(paddingStr + Publicity.ToCode("", " ") + Virtuality.ToCode("", " ") + "enum " + name); lines.Add(paddingStr + "{"); foreach (string literal in values) { lines.AddRange(Comments.CSharpComments(Comments.Key(name, literal), paddingStr + " ")); lines.Add(paddingStr + " " + literal + ","); } lines.Add(paddingStr + "}"); if (Packages.IsInPackage(name)) { padding -= 4; paddingStr = paddingStr.Substring(4); lines.Add(paddingStr + "}"); } return(string.Join("\n", lines)); }
public override string ToUmlCode(int padding = 0) { string paddingStr = String.Concat(Enumerable.Repeat(" ", padding)); List <string> lines = new List <string> (); lines.AddRange(Comments.PrintComments(commentsKey, paddingStr)); string nameWithPackage = Packages.IsInPackage(name) ? Packages.GetPackage(name) + "." + name : name; lines.Add( paddingStr + Publicity.ToCode("", " ") + Virtuality.ToCode("", " ") + type.ToCode("", " ") + nameWithPackage + " : " + string.Join(", ", bases) ); lines.Add(paddingStr + " Attributes:"); foreach (IUmlObject obj in Content) { if (obj is UmlAttribute) { lines.Add(obj.ToUmlCode(padding + 4)); } } lines.Add(paddingStr + " Methods:"); foreach (IUmlObject obj in Content) { if (!(obj is UmlAttribute)) { lines.Add(obj.ToUmlCode(padding + 4)); } } return(string.Join("\n", lines)); }
public override string ToUmlCode(int padding = 0) { string paddingStr = String.Concat(Enumerable.Repeat(" ", padding)); List <string> lines = new List <string> (); lines.AddRange(Comments.PrintComments(commentsKey, paddingStr)); string nameWithPackage = Packages.IsInPackage(name) ? Packages.GetPackage(name) + "." + name : name; lines.Add(paddingStr + Publicity.ToCode("", " ") + Virtuality.ToCode("", " ") + "enum " + nameWithPackage); foreach (string literal in values) { lines.AddRange(Comments.PrintComments(Comments.Key(name, literal), paddingStr + " ")); lines.Add(paddingStr + " " + literal); } return(string.Join("\n", lines)); }
public override string ToTexCode() { List <string> lines = new List <string> (); string uml = Publicity.ToCode(@"\keyword{", "} ").Replace("public ", "") + Virtuality.ToCode(@"\keyword{", "} ") + (IsContructor ? "" : @"\ptype{" + returntype + @"} ") + @"\varname{" + name.ToTexCode() + "} ("; for (int i = 0; i < parameters.Length; ++i) { string[] parts = parameters [i].Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); if (i > 0) { uml += ", "; } if (parts.Length == 1) { uml += @"\ptype{" + parts [0] + @"}"; } else if (parts.Length > 1) { uml += @"\ptype{" + parts [0] + @"} \varname{" + parts [1].ToTexCode() + "}"; } } uml += ")"; // lines.Add (@"\item[" + uml + @"] \item[]"); lines.Add(@"\textbf{" + uml + @"}\newline\newline"); foreach (string _cmt in Comments.GetComments(commentsKey)) { string cmt = _cmt; if (cmt.StartsWith("[") && cmt.EndsWith("]") && cmt.Contains("=")) { continue; } for (int i = 0; i < parameters.Length; ++i) { string[] parts = parameters [i].Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 1) { cmt = cmt.Replace(parts [1], @"\param{" + parts [1] + @"}"); } } cmt = Packages.AddTexCommands(cmt); lines.Add(cmt); } return(string.Join("\n", lines)); }
public override string ToTexCode() { List <string> lines = new List <string> (); string uml = Publicity.ToCode(@"\keyword{", "} ").Replace("public ", "") + Virtuality.ToCode(@"\keyword{", "} ").Replace("public ", "") + @"\ptype{" + type + @"} \varname{" + name + "}"; //lines.Add (@"\item[" + uml + @"] \item[]"); lines.Add(@"{\textbf{" + uml + @"}\newline\newline"); foreach (string cmt in Comments.GetComments(commentsKey)) { if (cmt.StartsWith("[") && cmt.EndsWith("]") && cmt.Contains("=")) { continue; } lines.Add(Packages.AddTexCommands(cmt)); } return(string.Join("\n", lines)); }
public string ToCSharpCode(int padding, Virtuality virt, UmlClass inClass) { if (virt == CSharpUML.Virtuality.None) { virt = Virtuality; } string paddingStr = String.Concat(Enumerable.Repeat(" ", padding)); List <string> lines = new List <string> (); lines.AddRange(Comments.CSharpComments(commentsKey, paddingStr)); string uml = paddingStr + ((inClass != null && inClass.type == ClassType.Interface) ? "" : Publicity.ToCode("", " ") + Virtuality.ToCode("", " ")); uml += type.ToCSharpType() + " " + name + " { get; set; }"; lines.Add(uml); return(string.Join("\n", lines)); }
public string ToCSharpCode(int padding, Virtuality virt, UmlClass inClass) { if (virt == CSharpUML.Virtuality.None) { virt = Virtuality; } string paddingStr = String.Concat(Enumerable.Repeat(" ", padding)); List <string> lines = new List <string> (); lines.AddRange(Comments.CSharpComments(commentsKey, paddingStr)); string uml = paddingStr; // public, virtual string _keywords = Comments.GetCommentParameter(commentsKey, "keywords"); if (_keywords != null) { uml += _keywords.TrimAll().ToCode("", " "); } else if (inClass != null && inClass.type == ClassType.Interface) { uml += ""; } else { uml += Publicity.ToCode("", " ") + virt.ToCode("", " "); } // return type string _returntype = Comments.GetCommentParameter(commentsKey, "returntype"); if (_returntype != null) { uml += _returntype.ToCSharpType() + " "; } else if (IsContructor) { uml += ""; } else if (returntype.Length > 0) { uml += returntype.ToCSharpType().ToCode("", " "); } else { uml += "void "; } // name string _name = Comments.GetCommentParameter(commentsKey, "name"); if (_name != null) { uml += _name; } else { uml += name; } // index operator [ ] if (name == "this") { uml += " [" + string.Join(", ", parameters) + "]"; lines.Add(uml); lines.Add(paddingStr + "{"); lines.Add(paddingStr + " " + "get { throw new System.NotImplementedException(); }"); lines.Add(paddingStr + " " + "set { throw new System.NotImplementedException(); }"); lines.Add(paddingStr + "}"); } // normal method else { uml += " ("; string _parameters = Comments.GetCommentParameter(commentsKey, "parameters"); if (_parameters != null) { uml += _parameters; } else { for (int i = 0; i < parameters.Length; ++i) { if (i > 0) { uml += ", "; } if (parameters [i].Contains(" ")) { String[] p = parameters [i].Split(new char[] { ' ' }, 2); uml += p [0].ToCSharpType() + " " + p [1]; } else { uml += parameters [i].ToCSharpType() + " " + parameters [i].ToLower(); } } } uml += ")"; if (uml.Contains("ModelFactory") && uml.Contains("Func<")) { uml = paddingStr + "public ModelFactory (Func<GameScreen, GameModelInfo, GameModel> createModel)"; } string _base = Comments.GetCommentParameter(commentsKey, "base"); if (_base != null) { uml += "\n" + paddingStr + " : base(" + _base.TrimAll() + ")"; } if (inClass.type == ClassType.Interface) { lines.Add(uml + ";"); } else { lines.Add(uml); lines.Add(paddingStr + "{"); lines.Add(paddingStr + " " + "throw new System.NotImplementedException();"); lines.Add(paddingStr + "}"); } } return(string.Join("\n", lines)); }
public override string ToCSharpCode(int padding = 0) { string paddingStr = String.Concat(Enumerable.Repeat(" ", padding)); List <string> lines = new List <string> (); lines.AddRange(Packages.GetUsingStatements(Packages.GetPackage(name))); if (Packages.IsInPackage(name)) { lines.Add(paddingStr + "namespace " + Packages.GetPackage(name)); lines.Add(paddingStr + "{"); paddingStr += " "; padding += 4; } lines.AddRange(Comments.CSharpComments(commentsKey, paddingStr)); lines.Add( paddingStr + Publicity.ToCode("", " ") + Virtuality.ToCode("", " ") + type.ToCode("", " ") + name + (bases.Length > 0 ? " : " + string.Join(", ", bases).Replace("XNA.", "") : "") ); lines.Add(paddingStr + "{"); lines.Add(""); IEnumerable <UmlAttribute> attributes = Content.OfType <UmlAttribute> (); IEnumerable <UmlMethod> contructors = Content.OfType <UmlMethod> ().Where((m) => m.Name == Name); IEnumerable <UmlMethod> methods = Content.OfType <UmlMethod> ().Where((m) => m.Name != Name); if (attributes.Count() > 0) { lines.Add(paddingStr + " #region Properties"); lines.Add(""); foreach (UmlAttribute obj in attributes) { lines.Add(obj.ToCSharpCode(padding + 4, Virtuality.Virtual, this)); lines.Add(""); } lines.Add(paddingStr + " #endregion"); lines.Add(""); } if (contructors.Count() > 0) { lines.Add(paddingStr + " #region Constructors"); lines.Add(""); foreach (UmlMethod obj in contructors) { obj.IsContructor = true; lines.Add(obj.ToCSharpCode(padding + 4, Virtuality.None, this)); lines.Add(""); } lines.Add(paddingStr + " #endregion"); lines.Add(""); } if (methods.Count() > 0) { lines.Add(paddingStr + " #region Methods"); lines.Add(""); foreach (UmlMethod obj in methods) { lines.Add(obj.ToCSharpCode(padding + 4, Virtuality.Virtual, this)); lines.Add(""); } lines.Add(paddingStr + " #endregion"); lines.Add(""); } lines.Add(paddingStr + "}"); if (Packages.IsInPackage(name)) { padding -= 4; paddingStr = paddingStr.Substring(4); lines.Add(paddingStr + "}"); } return(string.Join("\n", lines)); }