示例#1
0
 private static GameState Deserialize(ChessCore.DBManaging.Game g)
 {
     BinaryFormatter formatter = new BinaryFormatter();
     MemoryStream stream = new MemoryStream(g.GameData.ToArray());
     GameState gs = (GameState)formatter.Deserialize(stream);
     return gs;
 }
示例#2
0
 public static bool UpdateGame(ChessCore.GameObject gs)
 {
     try
     {
       using (DataContextDataContext dc = new DataContextDataContext())
       {
     var data = (from G in dc.Games
                 where G.Id == gs.gameId
                 select G).FirstOrDefault();
     if (data == null) return false;
     data.GameData = Serialize(gs);
     data.GameStatus = (int) gs.status;
     dc.SubmitChanges();
       }
       return true;
     }
     catch (Exception)
     {
       return false;
     }
 }