GetUsingStatements() public static method

public static GetUsingStatements ( ) : IEnumerable
return IEnumerable
Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }