コード例 #1
0
ファイル: SqlDataSource.cs プロジェクト: Amarg0/C-
        public void Parse()
        {
            foreach (var xElement in  XDoc.Descendants("db").Descendants("Groups"))
            {
                    foreach (var xxElement in xElement.Descendants("id"))
                    {
                        _groupId = int.Parse(xxElement.Value);
                    }

                    foreach (var xxElement in xElement.Descendants("Description"))
                    {
                        _description = xxElement.Value;
                    }

                    Groups[_groupsQuant] = new Group(_groupId, _description);
                    _groupsQuant++;
            }

            foreach (var xElement in XDoc.Descendants("db").Descendants("Students"))
            {
                foreach (var xxElement in xElement.Descendants("id"))
                {
                    _studentId = int.Parse(xxElement.Value);
                }

                foreach (var xxElement in xElement.Descendants("group_id"))
                {
                    _studentGroupId = int.Parse(xxElement.Value);
                }
                foreach (var xxElement in xElement.Descendants("stud_name"))
                {
                    _name = xxElement.Value;
                }

                foreach (var xxElement in xElement.Descendants("enroll_year"))
                {
                    _enrollYear = int.Parse(xxElement.Value);
                }
                _students[_studentsQuant]=new Student(_studentId,_studentGroupId,_name,_enrollYear);
                _studentsQuant++;
            }
        }
コード例 #2
0
ファイル: TxtDataSource.cs プロジェクト: Amarg0/C-
        public void Parse()
        {
            for (var i = 1; i < _groupCounter + 1; i++)
                if (Regex.IsMatch(_lines[i], Regex2))
                {
                    Groups[_groupsQuant] = new Group(int.Parse(_lines[i].Remove(_lines[i].IndexOf(";"))),
                        (_lines[i].Substring(_lines[i].IndexOf(";") + 1)).Remove(
                            (_lines[i].Substring(_lines[i].IndexOf(";") + 1)).IndexOf(";")));
                    _groupsQuant++;
                }

            for (var i = (_groupCounter + 2); i < (_groupCounter + 2 + _studentCounter); i++)
            {
                if (!Regex.IsMatch(_lines[i], Regex3)) continue;
                var kusok0 = _lines[i].Remove(_lines[i].IndexOf(";"));
                var kusok1 = _lines[i].Remove(_lines[i].LastIndexOf(";"));
                var kusok2 = kusok1.Remove(kusok1.LastIndexOf(";"));
                var kusok3 = kusok2.Remove(0, kusok0.Length + 1);
                var kusok4 = kusok1.Remove(0, kusok2.Length + 1);
                var kusok5 = _lines[i].Remove(0, kusok1.Length + 1);

                _studentId = int.Parse(kusok0);
                _studentGroupId = int.Parse(kusok3);
                _name = kusok4;
                _enrollYear = int.Parse(kusok5);

                _students[_studentsQuant] = new Student(_studentId, _studentGroupId, _name, _enrollYear);
                _studentsQuant++;
            }
        }
コード例 #3
0
ファイル: XmlDataSource.cs プロジェクト: Amarg0/C-
        public void Parse()
        {
            Console.WriteLine("Парсинг");
            Console.WriteLine("---------------------");
            foreach (var xElement in XDoc.Descendants("group").Where(xElement => xElement.HasAttributes))
            {
                if (xElement.Attribute("id") != null)
                {
                    group_id = int.Parse(xElement.Attribute("id").Value);
                }

                if (xElement.Attribute("description") != null)
                {
                    description = xElement.Attribute("description").Value;

                }
                Groups[groups_quant] = new Group(group_id,description);
                groups_quant++;
            }
            foreach (XElement xElement in XDoc.Descendants("student").Where(xElement => xElement.HasAttributes))
            {
                if (xElement.Attribute("id") != null)
                {
                    student_id = int.Parse(xElement.Attribute("id").Value);
                }
                if (xElement.Attribute("groupid") != null)
                {
                    student_group_id = int.Parse(xElement.Attribute("groupid").Value);
                }
                if (xElement.Attribute("name") != null)
                {
                    name = xElement.Attribute("name").Value;
                }
                if (xElement.Attribute("year") != null)
                {
                    enroll_year = int.Parse(xElement.Attribute("year").Value);
                }
                Students[students_quant] = new Student(student_id, student_group_id, name, enroll_year);
                students_quant++;
            }
        }