public Dictionary <int, Set> LoadData()
        {
            var fileSets = Path.Combine(folderData, "sets.json");

            LogExt.LogReadFile(fileSets);
            var content = File.ReadAllText(fileSets);
            var data    = JsonConvert.DeserializeObject <ICollection <dynamic> >(content);

            var dataCurated = data
                              .Where(i => string.IsNullOrWhiteSpace(i.Code?.ToString()) == false)
                              .Where(i => Convert.ToInt32(i.MtgaId ?? 0) > 0)
                              .Select(i => new Set
            {
                Arenacode   = i.CodeArena,
                Collation   = i.MtgaId,
                Code        = i.Code,
                ReleaseDate = i.ReleaseDate,
                Scryfall    = i.CodeScryfall,
                Tile        = 0
            })
                              .ToArray();

            var ret = dataCurated.ToDictionary(i => i.Collation, i => i);

            return(ret);
        }
Beispiel #2
0
        public Dictionary <string, DraftRatings> LoadData()
        {
            var fileSets = Path.Combine(folderData, "draftRatings.json");

            LogExt.LogReadFile(fileSets);
            var content         = File.ReadAllText(fileSets);
            var ratingsBySource = JsonConvert.DeserializeObject <Dictionary <string, DraftRatings> >(content);

            return(ratingsBySource);
        }
 public void LoadEventsFromDisk()
 {
     if (File.Exists(path))
     {
         LogExt.LogReadFile(path);
         var eventCollection =
             JsonConvert.DeserializeObject <ICollection <GetActiveEventsV2Raw> >(File.ReadAllText(path));
         cache.AddEvents(eventCollection);
     }
 }
Beispiel #4
0
        public Dictionary <int, Card> LoadData()
        {
            var fileSets = Path.Combine(folderData, "AllCardsCached2.json");

            LogExt.LogReadFile(fileSets);
            var content = File.ReadAllText(fileSets);
            var data    = JsonConvert.DeserializeObject <ICollection <Card2> >(content);

            var dataOldFormat = data.Select(c => new Card(c)).ToDictionary(i => i.grpId);

            return(dataOldFormat);
        }
        public Dictionary <int, Set> LoadData()
        {
            var fileSets = Path.Combine(folderData, "sets.json");

            LogExt.LogReadFile(fileSets);
            var content = File.ReadAllText(fileSets);
            var data    = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(content);

            var dataCurated = data
                              .Where(i => string.IsNullOrWhiteSpace(i.Key) == false)
                              .Where(i => Convert.ToInt32(i.Value.collation) > 0)
                              .Select(i => JsonConvert.DeserializeObject <Set>(JsonConvert.SerializeObject(i.Value)))
                              .Cast <Set>()
                              .ToArray();

            return(dataCurated.ToDictionary(i => i.Collation, i => i));
        }
 public void LoadEventsFromDisk()
 {
     if (File.Exists(path))
     {
         LogExt.LogReadFile(path);
         var fileText = File.ReadAllText(path);
         ICollection <GetActiveEventsV3Raw> eventCollection;
         try
         {
             eventCollection = JsonConvert.DeserializeObject <ICollection <GetActiveEventsV3Raw> >(fileText) ?? new GetActiveEventsV3Raw[0];
         }
         catch (Exception)
         {
             eventCollection = new GetActiveEventsV3Raw[0];
         }
         cache.AddEvents(eventCollection);
     }
 }
        public Dictionary <int, Card> LoadData()
        {
            var fileSets = Path.Combine(folderData, "AllCardsCached2.json");

            LogExt.LogReadFile(fileSets);
            var content       = File.ReadAllText(fileSets);
            var dataOldFormat = JsonConvert.DeserializeObject <ICollection <Card2> >(content)
                                .Select(c => new Card(c))
                                .ToArray();

            // Patch to support multiple cards with an Arena Id of 0
            var iNewId = dataOldFormat.Max(i => i.grpId) + 1;

            foreach (var cardMissingId in dataOldFormat.Where(i => i.grpId == 0).Skip(1))
            {
                cardMissingId.grpId = iNewId++;
            }

            return(dataOldFormat.ToDictionary(i => i.grpId));
        }