Example #1
0
        //============================================================
        // <T>解析单个文件。</T>
        //
        // @param file 要解析的文件
        //============================================================
        public void ParserSingleFile(FileInfo file)
        {
            FStrings strLines = FCsParser.GetLines(new FFileInfo(file.FullName));

            for (int n = 0; n < strLines.Count; n++)
            {
                if (FCsParser.IsSpace(strLines[n].ToString()))
                {
                    string space = string.Empty;
                    int    endindex = FCsSpace.ParserSpace(strLines, n, out space);
                    int    start, end = CheckParaAnnotate(strLines, n, out start);
                    for (int i = n; i < endindex; i++)
                    {
                        if (IsInInterregional(i, start, end))
                        {
                            continue;
                        }
                        if (FCsSpace.IsClass(strLines[i].ToString()))
                        {
                            string   classStr = FCsClass.ParserClass(strLines, i);
                            FMapNode node     = new FMapNode(classStr, space);
                            AddNode(node);
                            n = i;
                        }
                    }
                }
            }
        }
Example #2
0
        //============================================================
        // <T>获取类。</T>
        // @parame strline 需要获取的字符串集合。
        // @param index 当前索引
        // @return 获取的类对象
        //============================================================
        public void ParserClass(FStrings strLine, FCsSpace space, int index, string path, FClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative)
        {
            FXmlDocument doc        = new FXmlDocument();
            FXmlNode     config     = doc.Root;
            FXmlNode     nodeSpace  = space.XMLMaker(config);
            FXmlNode     xmlClass   = XMLMaker(nodeSpace, indextable, swPrint, file, relative);
            FXmlNode     fields     = new FXmlNode("Fields");
            FXmlNode     properties = new FXmlNode("Properties");
            FXmlNode     methods    = new FXmlNode("Methods");

            MakeInterfaceNode(this.Interface, xmlClass, indextable);
            xmlClass.Push(fields);
            xmlClass.Push(properties);
            xmlClass.Push(methods);
            int start, end = CheckParaAnnotate(strLine, index, out start);

            for (int n = _startIndex; n < _endIndex; n++)
            {
                if (IsInInterregional(n, start, end))
                {
                    continue;
                }
                if (IsField(strLine[n]))
                {
                    FCsField field = new FCsField(strLine, n);
                    field.Parser(fields, indextable, swPrint, file, relative);
                }
                if (IsProperty(strLine[n]))
                {
                    FCsProperty property = new FCsProperty(strLine, n, GetPairNum(strLine, n));
                    property.ParserPorperty(properties, indextable, swPrint, file, relative);
                }
                if (IsMethod(strLine[n]))
                {
                    int       endIndex = GetPairNum(strLine, n);
                    FCsMethod method   = new FCsMethod();
                    method.FillValue(strLine, n, endIndex);
                    method.ParserMethod(strLine, n, methods, indextable, swPrint, file, relative);
                    this.Method.Add(method);
                }
                if (FCsSpace.IsClass(strLine[n + 1]))
                {
                    SaveSXMLFile(path, doc);
                    FillValue(strLine, n + 1, GetPairNum(strLine, n + 1));
                    ParserClass(strLine, space, n + 1, path, indextable, swPrint, file, relative);
                }
            }
            SaveSXMLFile(path, doc);
        }