public static void Set(string key, TexturePageEntry entry)
 {
     lock (padlock)
     {
         entry.IsDirty = true;
         Entries[key]  = entry;
     }
 }
        public static void Load()
        {
            var xmlPath = Path.Combine(RootDirectory, "TexturePageEntries.xml");
            var binPath = Path.Combine(RootDirectory, "TexturePageEntries.bin");

            Entries.Clear();

            if (!File.Exists(xmlPath) || !File.Exists(binPath))
            {
                return;
            }

            Console.Write("Loading TPE cache... ");
            activeBinStream = File.OpenRead(binPath);

            var xml = new XmlDocument();

            xml.Load(xmlPath);

            foreach (XmlNode xmlTpe in xml.SelectNodes("/Entries/*"))
            {
                var entry = new TexturePageEntry();
                entry.Name          = xmlTpe.Attributes["name"].Value;
                entry.XOffset       = int.Parse(xmlTpe.Attributes["xoffset"].Value);
                entry.YOffset       = int.Parse(xmlTpe.Attributes["yoffset"].Value);
                entry.CropWidth     = int.Parse(xmlTpe.Attributes["cropWidth"].Value);
                entry.CropHeight    = int.Parse(xmlTpe.Attributes["cropHeight"].Value);
                entry.OW            = int.Parse(xmlTpe.Attributes["ow"].Value);
                entry.OH            = int.Parse(xmlTpe.Attributes["oh"].Value);
                entry.W             = int.Parse(xmlTpe.Attributes["w"].Value);
                entry.H             = int.Parse(xmlTpe.Attributes["h"].Value);
                entry.HasAlpha      = bool.Parse(xmlTpe.Attributes["hasAlpha"].Value);
                entry.Hash          = uint.Parse(xmlTpe.Attributes["hash"].Value);
                entry.BinOffset     = uint.Parse(xmlTpe.Attributes["binOffset"].Value);
                entry.BinSize       = uint.Parse(xmlTpe.Attributes["binSize"].Value);
                entry.CacheFileName = xmlTpe.Attributes["key"].Value;
                entry.TimestampUtc  = DateTime.FromBinary(long.Parse(xmlTpe.Attributes["tsUtc"].Value));
                Entries.Add(entry.CacheFileName, entry);
            }

            Console.WriteLine("Done!");
        }