拼图反序列化的上下文。
Exemple #1
0
 /// <summary>
 /// 打开拼图游戏。
 /// </summary>
 /// <param name="fileName">要打开的拼图游戏存档路径。</param>
 /// <param name="ct">取消任务的通知。</param>
 /// <returns>打开拼图游戏的任务。</returns>
 public Task OpenGame(string fileName, CancellationToken ct)
 {
     using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
     {
         JigsawSerializeContext context   = new JigsawSerializeContext(this.devices);
         BinaryFormatter        formatter = new BinaryFormatter(null,
                                                                new StreamingContext(StreamingContextStates.File, context));
         this.gameInfo = (JigsawInfo)formatter.Deserialize(stream);
         this.pieces   = (JigsawPieceCollection)formatter.Deserialize(stream);
     }
     this.gameChanged = false;
     return(this.StartGame(this.pieces, this.gameInfo, ct));
 }
		/// <summary>
		/// 打开拼图游戏。
		/// </summary>
		/// <param name="fileName">要打开的拼图游戏存档路径。</param>
		/// <param name="ct">取消任务的通知。</param>
		/// <returns>打开拼图游戏的任务。</returns>
		public Task OpenGame(string fileName, CancellationToken ct)
		{
			using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
			{
				JigsawSerializeContext context = new JigsawSerializeContext(this.devices);
				BinaryFormatter formatter = new BinaryFormatter(null,
					new StreamingContext(StreamingContextStates.File, context));
				this.gameInfo = (JigsawInfo)formatter.Deserialize(stream);
				this.pieces = (JigsawPieceCollection)formatter.Deserialize(stream);
			}
			this.gameChanged = false;
			return this.StartGame(this.pieces, this.gameInfo, ct);
		}