Пример #1
0
        public static DataSourceData Parse(XPOReader reader)
        {
            DataSourceData data = new DataSourceData();

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine().TrimStart();
                if (line.StartsWith(KeyWords.ENDDATASOURCE))
                {
                    break;
                }
                else if (line.StartsWith(KeyWords.Name))
                {
                    data.Name = line.Substring(KeyWords.Name.Length).Trim().Substring(1);
                }
                else if (line.StartsWith(KeyWords.METHODS))
                {
                    List <MethodData> methods = ParseMethods(reader);
                    foreach (MethodData m in methods)
                    {
                        data.AddMethod(m);
                    }
                }
                else if (line.StartsWith(KeyWords.FIELDLIST))
                {
                    ParseFieldList(reader, data);
                }
                else if (line.StartsWith(KeyWords.ENDDATASOURCE))
                {
                    break;
                }
            }

            return(data);
        }
Пример #2
0
        public static ReferenceFieldData Parse(string firstLine, XPOReader reader)
        {
            ReferenceFieldData data = new ReferenceFieldData();

            data.Name = firstLine.TrimStart().Substring(KeyWords.REFERENCEFIELD.Length).Trim();

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine().TrimStart();
                if (line.StartsWith(KeyWords.METHODS))
                {
                    List <MethodData> methods = ParseMethods(reader);
                    foreach (MethodData m in methods)
                    {
                        data.AddMethod(m);
                    }
                }
                else if (line.StartsWith(KeyWords.ENDREFERENCEFIELD))
                {
                    break;
                }
            }

            return(data);
        }
Пример #3
0
        public static SSRSData Parse(string path)
        {
            SSRSData  data = new SSRSData();
            XPOReader reader;

            using (reader = new XPOReader(path))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine().TrimStart();
                    if (line.StartsWith(KeyWords.REPORT))
                    {
                        data.Name = line.Substring(KeyWords.REPORT.Length).Trim().Substring(1);
                    }
                    else if (line.StartsWith(KeyWords.ENDREPORT))
                    {
                        break;
                    }
                    else if (line.StartsWith("#"))
                    {
                        data.lineCount++;
                    }
                }
            }

            data.lineCountOfFile = reader.LineCountOfFile;
            return(data);
        }
Пример #4
0
        public static QueryData Parse(string path)
        {
            XPOReader reader;
            QueryData data = new QueryData();

            using (reader = new XPOReader(path))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine().TrimStart();
                    if (line.StartsWith(KeyWords.QUERY))
                    {
                        data.Name = line.Substring(KeyWords.QUERY.Length).Trim().Substring(1);
                    }
                    else if (line.StartsWith(KeyWords.ENDQUERY))
                    {
                        break;
                    }
                    else if (line.StartsWith(KeyWords.METHODS))
                    {
                        List <MethodData> methods = ParseMethods(reader);
                        foreach (MethodData m in methods)
                        {
                            data.AddMethod(m);
                        }
                    }
                }
            }

            data.lineCountOfFile = reader.LineCountOfFile;
            return(data);
        }
Пример #5
0
        public static ControlData Parse(string firstLine, XPOReader reader)
        {
            ControlData data = new ControlData();

            int pos = firstLine.LastIndexOf('#');

            if (pos >= 0)
            {
                data.Name = firstLine.Substring(pos + 1).Trim();
            }

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine().TrimStart();
                if (line.StartsWith(KeyWords.ENDCONTROL))
                {
                    break;
                }
                else if (line.StartsWith(KeyWords.Name))
                {
                    data.Name = line.Substring(KeyWords.Name.Length).Trim().Substring(1);
                }
                else if (line.StartsWith(KeyWords.METHODS))
                {
                    List <MethodData> methods = ParseMethods(reader);
                    foreach (MethodData m in methods)
                    {
                        data.AddMethod(m);
                    }
                }
            }

            return(data);
        }
Пример #6
0
        public static ViewData Parse(string path)
        {
            ViewData  data = new ViewData();
            XPOReader reader;

            using (reader = new XPOReader(path))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine().Trim();
                    if (line.StartsWith(KeyWords.VIEW) && string.IsNullOrEmpty(data.Name))
                    {
                        data.Name = line.Substring(KeyWords.VIEW.Length).Trim().Substring(1);
                    }
                    else if (line == KeyWords.ENDVIEW)
                    {
                        break;
                    }
                    else if (line == KeyWords.METHODS)
                    {
                        List <MethodData> methods = ParseMethods(reader);
                        foreach (MethodData m in methods)
                        {
                            data.AddMethod(m);
                        }
                    }
                }
            }
            data.lineCountOfFile = reader.LineCountOfFile;
            return(data);
        }
Пример #7
0
 private static void ParseIndices(XPOReader reader)
 {
     while (!reader.EndOfStream)
     {
         string line = reader.ReadLine().TrimStart();
         if (line.StartsWith(KeyWords.ENDINDICES))
         {
             break;
         }
     }
 }
Пример #8
0
 protected static void SkipTo(XPOReader reader, string symbol)
 {
     while (!reader.EndOfStream)
     {
         string line = reader.ReadLine().TrimStart();
         if (line.StartsWith(symbol))
         {
             break;
         }
     }
 }
Пример #9
0
 private static void ParseDataSources(XPOReader reader, FormData data)
 {
     while (!reader.EndOfStream)
     {
         string line = reader.ReadLine().TrimStart();
         if (line.StartsWith(KeyWords.DATASOURCE))
         {
             data.AddDataSource(DataSourceData.Parse(reader));
         }
         else if (line.StartsWith(KeyWords.ENDOBJECTBANK))
         {
             break;
         }
     }
 }
Пример #10
0
 private static void ParseDesign(XPOReader reader, FormData data)
 {
     while (!reader.EndOfStream)
     {
         string line = reader.ReadLine().TrimStart();
         if (line.StartsWith(KeyWords.CONTROL))
         {
             data.AddControl(ControlData.Parse(line, reader));
         }
         else if (line.StartsWith(KeyWords.ENDDESIGN))
         {
             break;
         }
     }
 }
Пример #11
0
        public static MethodData Parse(string firstLine, XPOReader reader)
        {
            MethodData method = new MethodData();

            method.Name = firstLine.Substring(KeyWords.SOURCE.Length).Trim().Substring(1);

            Dictionary <string, Stack <int> > tagMap = new Dictionary <string, Stack <int> >();

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine().TrimStart();
                if (line.StartsWith("#"))
                {
                    method.LineCount++;
                    string tag = GetTag(line);
                    if (tag != null)
                    {
                        if (tag.StartsWith("/"))
                        {
                            tag = tag.Substring(1);
                            if (tagMap.ContainsKey(tag) && tagMap[tag].Count > 0)
                            {
                                TagData td = new TagData();
                                td.Name      = tag;
                                td.StartLine = tagMap[tag].Pop();
                                td.LineCount = method.LineCount - td.StartLine + 1;
                                method.tags.Add(td);
                            }
                        }
                        else
                        {
                            if (!tagMap.ContainsKey(tag))
                            {
                                tagMap[tag] = new Stack <int>();
                            }
                            tagMap[tag].Push(method.LineCount);
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            return(method);
        }
Пример #12
0
 private static void ParseFieldList(XPOReader reader, DataSourceData data)
 {
     while (!reader.EndOfStream)
     {
         string line = reader.ReadLine().TrimStart();
         if (line.StartsWith(KeyWords.DATAFIELD))
         {
             data.AddDataField(DataFieldData.Parse(line, reader));
         }
         else if (line.StartsWith(KeyWords.REFERENCEFIELD))
         {
             data.AddReferenceField(ReferenceFieldData.Parse(line, reader));
         }
         else if (line.StartsWith(KeyWords.ENDFIELDLIST))
         {
             break;
         }
     }
 }
Пример #13
0
        public static TableData Parse(string path)
        {
            XPOReader reader;
            TableData data = new TableData();

            using (reader = new XPOReader(path))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine().TrimStart();
                    if (line.StartsWith(KeyWords.TABLE))
                    {
                        data.Name = line.Substring(KeyWords.TABLE.Length).Trim().Substring(1);
                    }
                    else if (line.StartsWith(KeyWords.ENDTABLE))
                    {
                        break;
                    }
                    else if (line.StartsWith(KeyWords.METHODS))
                    {
                        List <MethodData> methods = ParseMethods(reader);
                        foreach (MethodData m in methods)
                        {
                            data.AddMethod(m);
                        }
                    }
                    else if (line.StartsWith(KeyWords.REFERENCES))
                    {
                        ParseReferences(reader);
                    }
                    else if (line.StartsWith(KeyWords.INDICES))
                    {
                        ParseIndices(reader);
                    }
                }
            }

            data.lineCountOfFile = reader.LineCountOfFile;
            return(data);
        }
Пример #14
0
        public static FormData Parse(string path)
        {
            XPOReader reader;
            FormData  data = new FormData();

            using (reader = new XPOReader(path))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine().TrimStart();
                    if (string.IsNullOrEmpty(data.Name) && line.StartsWith(KeyWords.FORM))
                    {
                        data.Name = line.Substring(KeyWords.FORM.Length).Trim().Substring(1);
                    }
                    else if (line.StartsWith(KeyWords.ENDFORM))
                    {
                        break;
                    }
                    else if (line.StartsWith(KeyWords.METHODS))
                    {
                        List <MethodData> methods = ParseMethods(reader);
                        foreach (MethodData m in methods)
                        {
                            data.AddMethod(m);
                        }
                    }
                    else if (line.StartsWith(KeyWords.DESIGN))
                    {
                        ParseDesign(reader, data);
                    }
                    else if (line.StartsWith(KeyWords.OBJECTBANK))
                    {
                        ParseDataSources(reader, data);
                    }
                }
            }

            data.lineCountOfFile = reader.LineCountOfFile;
            return(data);
        }
Пример #15
0
        protected static List <MethodData> ParseMethods(XPOReader reader)
        {
            List <MethodData> methods = new List <MethodData>();

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine().TrimStart();
                if (line.StartsWith(KeyWords.SOURCE))
                {
                    methods.Add(MethodData.Parse(line, reader));
                }
                else if (line.StartsWith(KeyWords.ENDMETHODS))
                {
                    break;
                }
                else
                {
                    continue;
                }
            }

            return(methods);
        }