public void Store(SolutionDTO sol)
        {
            if (sol.SolutionId == 0)
            {
                sol.SolutionId = data.NextId++;
            }
            if (data.ByPuzzles.TryGetValue(sol.PuzzleIdent, out var s))
            {
                var exists = s.IndexOf(sol);
                if (exists < 0)
                {
                    s.Add(sol);
                }
                else
                {
                    s[exists] = sol;
                }
            }
            else
            {
                data.ByPuzzles[sol.PuzzleIdent] = new List <SolutionDTO>()
                {
                    sol
                };
            }

            System.IO.File.WriteAllText(file, JsonConvert.SerializeObject(data, Formatting.Indented));
        }
Exemplo n.º 2
0
 protected bool Equals(SolutionDTO other)
 {
     return(SolutionId == other.SolutionId && PuzzleIdent == other.PuzzleIdent);
 }