Beispiel #1
0
        public static bool TryLoadQuestHtml(string filePath, out QuestFile questFile)
        {
            string html = String.Empty;

            using (var stream = new StreamReader(filePath, Encoding.UTF8)) {
                var doc = HDocument.Load(stream);
                html = doc.ToString();
            }

            questFile = null;

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(html.ToString().ToCharArray()))) {
                try {
                    XmlSerializer ser = new XmlSerializer(typeof(QuestFile));
                    questFile          = (QuestFile)ser.Deserialize(ms);
                    questFile.fileName = Path.GetFileName(filePath);
                } catch (Exception ex) {
                    Debug.Print(ex.ToString());
                }
            }
            return(questFile != null);
        }
Beispiel #2
0
        public static bool TryLoadQuestHtml(string filePath, out QuestFile questFile)
        {
            string html = String.Empty;
            using (var stream = new StreamReader(filePath, Encoding.UTF8)) {
                var doc = HDocument.Load(stream);
                html = doc.ToString();
            }

            questFile = null;

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(html.ToString().ToCharArray()))) {
                try {
                    XmlSerializer ser = new XmlSerializer(typeof(QuestFile));
                    questFile = (QuestFile)ser.Deserialize(ms);
                    questFile.fileName = Path.GetFileName(filePath);
                } catch (Exception ex) {
                    Debug.Print(ex.ToString());
                }
            }
            return questFile != null;
        }