Beispiel #1
0
        public static void LoadManualStructure(string FileName)
        {
            var StructureXml = XDocument.Load(FileName);

            manual = (from _manual in StructureXml.Elements("Manual")
                      select new Manual
            {
                Title = _manual.Element("Info").Element("Title").Value,
                Author = _manual.Element("Info").Element("Author").Value,
                Preface = new Topic()
                {
                    Type = _manual.Element("Info").Element("Preface").Attribute("Type").Value,
                    ID = _manual.Element("Info").Element("Preface").Attribute("ID").Value
                },
                Chapters = (from _chapter in _manual.Element("Chapters").Elements("Chapter")
                            let xElement = _chapter.Element("Preface") ?? new XElement("Preface")
                                           select new Chapter
                {
                    No = _chapter.Attribute("No").Value,
                    Title = _chapter.Attribute("Title").Value,
                    Preface = new Topic()
                    {
                        Type = xElement.Attribute("Type").Value,
                        ID = xElement.Attribute("ID").Value,
                        FileTitle = xElement.Attribute("FileTitle") != null ? xElement.Attribute("FileTitle").Value : ""
                    },
                    Topics = (from _topic in _chapter.Element("Topics").Elements("Topic")
                              let element = _topic.Element("SubTopics") ?? new XElement("SubTopics")
                                            select new Topic
                    {
                        Type = _topic.Attribute("Type").Value,
                        ID = _topic.Attribute("ID").Value,
                        FileTitle = _topic.Attribute("FileTitle") != null ? _topic.Attribute("FileTitle").Value : "",
                        SubTopics = (from _sub in element.Elements("SubTopic")
                                     select new Topic
                        {
                            Type = _sub.Attribute("Type").Value,
                            ID = _sub.Attribute("ID").Value,
                            FileTitle = _sub.Attribute("FileTitle") != null ? _sub.Attribute("FileTitle").Value : ""
                        }).ToList()
                    }).ToList()
                }).ToList()
            }).First() as Manual;
        }
Beispiel #2
0
 public static void LoadManualStructure(string FileName)
 {
     var StructureXml = XDocument.Load(FileName);
     manual = (from _manual in StructureXml.Elements("Manual")
               select new Manual
               {
                   Title = _manual.Element("Info").Element("Title").Value,
                   Author = _manual.Element("Info").Element("Author").Value,
                   Preface = new Topic()
                   {
                       Type = _manual.Element("Info").Element("Preface").Attribute("Type").Value,
                       ID = _manual.Element("Info").Element("Preface").Attribute("ID").Value
                   },
                   Chapters = (from _chapter in _manual.Element("Chapters").Elements("Chapter")
                               let xElement = _chapter.Element("Preface") ?? new XElement("Preface")
                               select new Chapter
                               {
                                   No = _chapter.Attribute("No").Value,
                                   Title = _chapter.Attribute("Title").Value,
                                   Preface = new Topic()
                                   {
                                       Type = xElement.Attribute("Type").Value,
                                       ID = xElement.Attribute("ID").Value,
                                       FileTitle =  xElement.Attribute("FileTitle") != null ? xElement.Attribute("FileTitle").Value : ""
                                   },
                                   Topics = (from _topic in _chapter.Element("Topics").Elements("Topic")
                                             let element = _topic.Element("SubTopics") ?? new XElement("SubTopics")
                                             select new Topic
                                             {
                                                 Type = _topic.Attribute("Type").Value,
                                                 ID = _topic.Attribute("ID").Value,
                                                 FileTitle =  _topic.Attribute("FileTitle") != null ? _topic.Attribute("FileTitle").Value : "",
                                                 SubTopics = (from _sub in element.Elements("SubTopic")
                                                              select new Topic
                                                              {
                                                                  Type = _sub.Attribute("Type").Value,
                                                                  ID = _sub.Attribute("ID").Value,
                                                                   FileTitle =  _sub.Attribute("FileTitle") != null ? _sub.Attribute("FileTitle").Value : ""
                                                              }).ToList()
                                             }).ToList()
                               }).ToList()
               }).First() as Manual;
 }