private static void Veto(AppState state, Rank veto) { state.CurrentRanks.Veto(veto); state.OwnVetos.Add(veto.Name); var file = Vetos.GetFile(state.Location, state.CurrentNameType, state.Id); Vetos.Save(file, state.OwnVetos); }
public AppState(string id, DirectoryInfo location, NameTypes nameTypes) { Id = string.IsNullOrWhiteSpace(id) ? "Unknown" : id; Location = location ?? new DirectoryInfo("."); NameTypes = nameTypes; CurrentNameType = nameTypes.IsSingleGender() ? nameTypes : NameTypes.Boys; Rnd = new MT19937Generator(); OwnBoyVetos = new List <Name>(Vetos.Load(Path.Combine(Location.FullName, Id + ".boys.vetos.txt")).Select(n => (Name)n)); OwnGirlVetos = new List <Name>(Vetos.Load(Path.Combine(Location.FullName, Id + ".girls.vetos.txt")).Select(n => (Name)n)); }
private Ranks GetRanks(NameTypes tp) { var votes = Location.EnumerateFiles(string.Format("*.{0}.xml", tp.ToString().ToLowerInvariant())); var vetos = Location.EnumerateFiles(string.Format("*.{0}.vetos.txt", tp.ToString().ToLowerInvariant())); var ranks = new Ranks( Names.FromDirectory(Location, tp).Distinct(), votes.SelectMany(file => Votes.Load(file)), vetos.SelectMany(file => Vetos.Load(file))) { NameType = tp }; ranks.Recalculate(); return(ranks); }