示例#1
0
        public static void AddFromLocalFile(string file, ConcurrentBag <SlotCache> db, ITrainerInfo dest, ICollection <string> validExtensions)
        {
            var fi = new FileInfo(file);

            if (!validExtensions.Contains(fi.Extension) || !PKX.IsPKM(fi.Length))
            {
                return;
            }

            var data = File.ReadAllBytes(file);

            _ = FileUtil.TryGetPKM(data, out var pk, fi.Extension, dest);
            if (pk?.Species is not > 0)
            {
                return;
            }

            var info  = new SlotInfoFile(file);
            var entry = new SlotCache(info, pk);

            db.Add(entry);
        }
示例#2
0
        public static void AddFromLocalFile(string file, ConcurrentBag <SlotCache> db, ITrainerInfo dest, ICollection <string> validExtensions)
        {
            var fi = new FileInfo(file);

            if (!validExtensions.Contains(fi.Extension) || !PKX.IsPKM(fi.Length))
            {
                return;
            }

            var data   = File.ReadAllBytes(file);
            var prefer = PKX.GetPKMFormatFromExtension(fi.Extension, dest.Generation);
            var pk     = PKMConverter.GetPKMfromBytes(data, prefer);

            if (pk?.Species is not > 0)
            {
                return;
            }

            var info  = new SlotInfoFile(file);
            var entry = new SlotCache(info, pk);

            db.Add(entry);
        }