/// <summary> /// This method does not saves other kingdoms. /// </summary> /// <param name="cards"></param> /// <returns></returns> public override BuyAgenda Load(IEnumerable <Card> cards) { var id = cards.ToId(); int i = (int)cards.OrderBy(c => c.Type).First().Type; lock (_lock) { try { using (var reader = new StreamReader($"{directoryPath}{prefix}{i}.txt")) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (!string.IsNullOrEmpty(line)) { if (line.Split(':')[0] == id) { return(BuyAgenda.FromString(line)); } } } } } catch { } } return(null); }
public override IEnumerator <BuyAgenda> GetEnumerator() { for (int i = 8; i < 32; i++) { lock (locks[i]) { try { if (files[i] == null) { LoadAllAgendas(i); } } catch { continue; } foreach (var item in files[i]) { yield return(BuyAgenda.FromString(item.Value)); } } } // free memory files = new Dictionary <string, string> [33]; }
public override IEnumerator <BuyAgenda> GetEnumerator() { for (int i = 8; i < 32; i++) { lock (_lock) if (File.Exists($"{directoryPath}{prefix}{i}.txt")) { using (var reader = new StreamReader($"{directoryPath}{prefix}{i}.txt")) while (!reader.EndOfStream) { yield return(BuyAgenda.FromString(reader.ReadLine())); } } } }
/// <summary> /// This method does saves other kingdoms. /// </summary> /// <param name="cards"></param> /// <returns></returns> public override BuyAgenda Load(IEnumerable <Card> cards) { var id = cards.ToId(); int i = cards.OrderBy(p => p.Type).Select(p => (int)p.Type).First(); try { if (files[i] == null) { LoadAllAgendas(i); } lock (locks[i]) return(BuyAgenda.FromString(files[i][id])); } catch (Exception) { return(null); } }