public static async Task BuildAllISPages(Dictionary <string, ISPage> pageMap, string roomId, string dirPath)
        {
            String baseHtml = null;
            ISPage page     = null;

            try
            {
                baseHtml = await ReadHtml(roomId);
            }
            catch (Exception e)
            {
                throw new ISParseException("Could not read Infinite Story webpage", e);
            }
            try
            {
                page = ISPageHtmlParser.ParseRawISHtml(baseHtml, roomId, dirPath);
            }
            catch (Exception e)
            {
                throw new ISParseException("Could not parse Infinite Story webpage", e);
            }

            pageMap.Add(roomId, page);
            List <Task> waitTasks = new List <Task>();

            foreach (String childRoomId in page.Choices.Select(x => x.RoomId))
            {
                if (!pageMap.ContainsKey(childRoomId))
                {
                    waitTasks.Add(BuildAllISPages(pageMap, childRoomId, dirPath));
                }
            }
            Task.WaitAll(waitTasks.ToArray());
        }
Пример #2
0
        private void BuildHtml(Dictionary <string, ISPage> pageMap, string roomId, string dirPath)
        {
            String baseHtml = ISPageHtmlParser.ReadHtml(roomId).Result;
            ISPage page     = ISPageHtmlParser.ParseRawISHtml(baseHtml, roomId, dirPath);

            pageMap.Add(roomId, page);
            SavePage(roomId, page, dirPath);
            foreach (String childRoomId in page.Choices.Select(x => x.RoomId))
            {
                if (!pageMap.ContainsKey(childRoomId))
                {
                    BuildHtml(pageMap, childRoomId, dirPath);
                }
            }
        }