CSharpUML.CSharpParser.Parse C# (CSharp) Метод

Parse() публичный Метод

public Parse ( char chars, int &i ) : CSharpBlock[]
chars char
i int
Результат CSharpBlock[]
        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 ();
        }

Same methods

CSharpParser::Parse ( IEnumerable lines ) : IEnumerable
CSharpParser::Parse ( string filename ) : IEnumerable

Usage Example

Пример #1
0
 private static void Code2Uml(IEnumerable <string> paths, string target)
 {
     foreach (string path in paths)
     {
         Console.WriteLine(path);
         Action <string> processFile = (filename) => {
             if (!filename.Contains("gen"))
             {
                 IParser parser = new CSharpParser();
                 IEnumerable <IUmlObject> objects = parser.Parse(filename);
                 List <string>            lines   = new List <string> ();
                 foreach (IUmlObject obj in objects)
                 {
                     lines.Add(obj.ToUmlCode());
                 }
                 string umlfile = filename.Replace(".cs", ".uml");
                 if (target.Length > 0)
                 {
                     umlfile = umlfile.ReplaceFirst(path, target + "/");
                 }
                 Console.WriteLine("Write: " + umlfile);
                 Files.WriteLines(umlfile, lines);
             }
         };
         Files.SearchFiles(path, new string[] { ".cs" }, processFile);
     }
 }
All Usage Examples Of CSharpUML.CSharpParser::Parse