示例#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;
                        }
                    }
                }
            }
        }
示例#2
0
        //============================================================
        // <T>产生doc节点。</T>
        //
        // @param space 命名空间对象
        // @return 根节点
        //============================================================
        public FXmlNode RootSpaceNode(FCsSpace space)
        {
            FXmlDocument doc       = new FXmlDocument();
            FXmlNode     config    = doc.Root;
            FXmlNode     nodeSpace = space.XMLMaker(config);

            return(nodeSpace);
        }
示例#3
0
        //============================================================
        // <T>获取命名空间和结束行索引。</T>
        // @parame strlines 需要获取的字符串集合。
        // @param index 当前索引
        // @param out string 获取的命名空间对象
        // @return 命名空间的结束行索引
        //============================================================
        public static int ParserSpace(FStrings strLines, int index, out string spaceString)
        {
            FCsSpace space   = new FCsSpace();
            int      end     = space.GetPairNum(strLines, index);
            string   strTemp = strLines[index].ToString().Trim();

            spaceString = space.GetSpaceName(strTemp);
            return(end);
        }
示例#4
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);
        }
示例#5
0
        //============================================================
        // <T>解析文件。</T>
        //
        // @parame fileinfo 要解析的文件
        // @param index 解析对象
        //============================================================
        public void ParserFile(FileInfo file, string outputPath, FClassesIndexTable indextable, StreamWriter swPrint, string relative)
        {
            FStrings lines = GetLines(file.DirectoryName + "\\" + file.Name);

            for (int n = 0; n < lines.Count; n++)
            {
                //string line = ConvertToUTF8 ( lines[n].ToString() );
                if (IsSpace(lines[n].ToString()))
                {
                    FCsSpace space = new FCsSpace();
                    space.FillValue(lines, n, space.GetPairNum(lines, n));
                    string path = outputPath + "\\" + space.SpaceName.Trim();
                    space.ParserSpace(lines, n, path, indextable, swPrint, file, relative);
                }
            }
        }