public string ToJsonDiff(GridState previous) { return string.Format("[{0}{1}]", jsonString(Description), string.Join("", Cells.Select((c,i) => c.ToJsonDiff(previous.Cells[i], i)) .Where(s => s != null) .Select(s => "," + s)) ); }
public bool HasChanged(GridState previous) { for (var i=0; i<81; i++) { if(Cells[i].Value != previous.Cells[i].Value || !Cells[i].Possibilities.SetEquals(previous.Cells[i].Possibilities)) return true; } return false; }
/// <summary> /// Loads the grid from an existing <see cref="GridState"/>. /// </summary> public void LoadState(GridState state) { for(var i=0;i<81;i++) { Cells[i].LoadState(state.Cells[i]); } }
/// <summary> /// Saves the current grid into a <see cref="GridState"/> using a particular description. /// </summary> public GridState SaveState(string description) { GridState state = new GridState { Description = description, Cells = new CellState[81] }; for (var i=0; i<81; i++) { state.Cells[i] = Cells[i].SaveState(); } return state; }
public void Add(GridState state) { States.Add(state); }