Ejemplo n.º 1
0
        internal WzDirectory ParseXMLWzDir(XmlElement dirElement)
        {
            WzDirectory result = new WzDirectory(dirElement.GetAttribute("name"));

            foreach (XmlElement subelement in dirElement)
            {
                if (subelement.Name == "wzdir")
                {
                    result.AddDirectory(ParseXMLWzDir(subelement));
                }
                else if (subelement.Name == "wzimg")
                {
                    result.AddImage(ParseXMLWzImg(subelement));
                }
                else
                {
                    throw new InvalidDataException("unknown XML prop " + subelement.Name);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
 private void RecursivelyLoadDirectory(WzDirectory dir, string directoryPath, WzMapleVersion mapleVersion)
 {
     if (!Directory.Exists(directoryPath))
     {
         return;
     }
     string[] files = Directory.GetFiles(directoryPath);
     foreach (string file in files)
     {
         FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read);
         WzImage    img    = new WzImage(Path.GetFileName(file), stream, mapleVersion);
         dir.AddImage(img);
     }
     files = Directory.GetDirectories(directoryPath);
     foreach (string sub in files)
     {
         WzDirectory subDir = new WzDirectory(Path.GetFileNameWithoutExtension(sub));
         RecursivelyLoadDirectory(subDir, sub, mapleVersion);
         dir.AddDirectory(subDir);
     }
 }
 internal WzDirectory ParseXMLWzDir(XmlElement dirElement)
 {
     WzDirectory result = new WzDirectory(dirElement.GetAttribute("name"));
     foreach (XmlElement subelement in dirElement)
     {
         if (subelement.Name == "wzdir")
             result.AddDirectory(ParseXMLWzDir(subelement));
         else if (subelement.Name == "wzimg")
             result.AddImage(ParseXMLWzImg(subelement));
         else throw new InvalidDataException("unknown XML prop " + subelement.Name);
     }
     return result;
 }