Esempio n. 1
0
        public static bool Matches(CSharpBlock block)
        {
            string line = block.Name;

            // index operator?
            if (line.Contains("this [") && line.Contains("]"))
            {
                return(false);
            }

            // normal method?
            int indexBracketOpen  = line.IndexOf("(");
            int indexBracketClose = line.IndexOf(")");
            int indexEqualSign    = line.IndexOf("=");

            if (indexBracketOpen == -1 && indexBracketClose == -1)
            {
                return(true);
            }
            else if (indexEqualSign < indexBracketOpen)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public UmlMethod(CSharpBlock block, UmlClass classobj)
            : base(block)
        {
            parseParams();

            if (name.Contains(" "))
            {
                string[] p = name.CleanGenerics()
                             .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                returntype = p [0];
                name       = "";
                for (int i = 0; i < p.Length; ++i)
                {
                    name += i == 0 ? "" : " " + p [i];
                }
            }
            if (name == "")
            {
                name       = returntype;
                returntype = "";
            }
            if (returntype == "void")
            {
                returntype = "";
            }
            name = name.TrimAll();

            commentsKey = Comments.Key(classobj.Name, name, parameters.Unique() + returntype);
        }
Esempio n. 3
0
        public UmlClass(CSharpBlock block)
            : base(block)
        {
            name = name.IfContains("class ", () => type = ClassType.Class);
            name = name.IfContains("struct ", () => type = ClassType.Struct);
            name = name.IfContains("interface ", () => type = ClassType.Interface);

            string[] p = name.Split(":");
            if (p.Length == 2)
            {
                name  = p [0].Trim();
                bases = new HashSet <string> (p [1].Trim().Split(",").TrimAll()).ToArray();
            }
            else
            {
                bases = new string[] {};
            }

            Content = ParseContent(block.Content).ToArray();
            if (type == ClassType.Interface)
            {
                foreach (IUmlObject obj in Content)
                {
                    if (obj is UmlObject)
                    {
                        (obj as UmlObject).Publicity = CSharpUML.Publicity.Public;
                    }
                }
            }

            commentsKey = Comments.Key(name);
            Packages.AddToCurrentPackage(name);
        }
Esempio n. 4
0
        public CSharpBlock[] Parse(char[] chars, ref int i)
        {
            List <CSharpBlock> blocks = new List <CSharpBlock> ();
            string             desc   = "";
            int inBrackets            = 0;

            for (; i < chars.Length; ++i)
            {
                char c = chars [i];
                if (c == '(')
                {
                    ++inBrackets;
                }
                else if (c == ')')
                {
                    --inBrackets;
                }
                if (c == '{' && inBrackets == 0)
                {
                    desc = desc.Split(new string[] { ": base" }, StringSplitOptions.None) [0];
                    desc = desc.TrimAll();
                    //if (desc.Count () > 0) {
                    ++i;
                    CSharpBlock block = new CSharpBlock(
                        name: desc,
                        content: Parse(chars, ref i)
                        );
                    blocks.Add(block);
                    desc = "";
                }
                else if (c == '}' && inBrackets == 0)
                {
                    desc = desc.TrimAll();
                    break;
                }
                else if (c == ';' && inBrackets == 0)
                {
                    desc = desc.Split(new string[] { ": base" }, StringSplitOptions.None) [0];
                    desc = desc.TrimAll();
                    if (desc.Count() > 0)
                    {
                        CSharpBlock block = new CSharpBlock(name: desc);
                        blocks.Add(block);
                        desc = "";
                    }
                }
                else
                {
                    desc += c;
                }
            }
            desc = desc.TrimAll();
            if (desc.Count() > 0)
            {
                CSharpBlock block = new CSharpBlock(name: desc);
                blocks.Add(block);
            }
            return(blocks.ToArray());
        }
Esempio n. 5
0
        public UmlEnum(CSharpBlock block)
            : base(block)
        {
            name   = name.IfContains("enum ", () => {});
            values = ParseContent(block.Content).ToArray();

            commentsKey = Comments.Key(name);
            Packages.AddToCurrentPackage(name);
        }
Esempio n. 6
0
        public UmlAttribute(CSharpBlock block, UmlClass classobj)
            : base(block)
        {
            name = name.Split('=') [0].TrimAll();

            if (name.Contains(" "))
            {
                string[] p = name.CleanGenerics()
                             .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                type = p [0];
                name = "";
                for (int i = 0; i < p.Length; ++i)
                {
                    name += i == 0 ? "" : " " + p [i];
                }
            }
            name = name.TrimAll();

            commentsKey = Comments.Key(classobj.Name, name);
        }
Esempio n. 7
0
 public UmlObject(CSharpBlock block)
     : this(block.Name)
 {
 }
Esempio n. 8
0
 public static bool Matches(CSharpBlock block)
 {
     return(block.Name.Contains("enum"));
 }
Esempio n. 9
0
 public static bool Matches(CSharpBlock block)
 {
     return(block.Name.Contains("class ") || block.Name.Contains("struct ") || block.Name.Contains("interface "));
 }