Example #1
0
        private List <Stories> Parse(string file)
        {
            XmlReader reader = null;

            try
            {
                XmlDocument       doc      = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                reader = XmlReader.Create(@file, settings);
                doc.Load(reader);
                List <Stories> list = new List <Stories>();
                foreach (XmlNode node in doc.ChildNodes)
                {
                    if (node.Name.Equals(StoriesPack))
                    {
                        foreach (XmlNode n in node.ChildNodes)
                        {
                            if (n.Name.Equals(StoriesStr))
                            {
                                Stories stories = ParseStories(n);
                                if (stories != null)
                                {
                                    list.Add(stories);
                                }
                            }
                        }
                    }
                }

                return(list);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Example #2
0
        private Stories ParseStories(XmlNode node)
        {
            try
            {
                Stories stories = new Stories();
                foreach (XmlNode n in node.ChildNodes)
                {
                    switch (n.Name)
                    {
                    case ConditionStr:
                    {
                        ParseCondition(n, stories.Condition);
                        break;
                    }

                    case ConfigStr:
                    {
                        ParseConfig(n, stories.Config);
                        break;
                    }

                    case StoryListStr:
                    {
                        ParseStoryList(n, stories.StoryList);
                        break;
                    }
                    }
                }

                stories.Check();

                return(stories);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }