public TaskState( NBTag tag ) { if( FormatVersion != tag["FormatVersion"].GetInt() ) throw new FormatException( "Incompatible format." ); Shapes = tag["Shapes"].GetInt(); Vertices = tag["Vertices"].GetInt(); ImprovementCounter = tag["ImprovementCounter"].GetInt(); MutationCounter = tag["MutationCounter"].GetInt(); TaskStart = DateTime.UtcNow.Subtract( TimeSpan.FromTicks( tag["ElapsedTime"].GetLong() ) ); ProjectOptions = new ProjectOptions( tag["ProjectOptions"] ); BestMatch = new DNA( tag["BestMatch"] ); CurrentMatch = BestMatch; Initializer = (IInitializer)ModuleManager.ReadModule( tag["Initializer"] ); Mutator = (IMutator)ModuleManager.ReadModule( tag["Mutator"] ); Evaluator = (IEvaluator)ModuleManager.ReadModule( tag["Evaluator"] ); byte[] imageBytes = tag["ImageData"].GetBytes(); using( MemoryStream ms = new MemoryStream( imageBytes ) ) { OriginalImage = new Bitmap( ms ); } var statsTag = (NBTList)tag["MutationStats"]; foreach( NBTag stat in statsTag ) { MutationType mutationType = (MutationType)Enum.Parse( typeof( MutationType ), stat["Type"].GetString() ); MutationCounts[mutationType] = stat["Count"].GetInt(); MutationImprovements[mutationType] = stat["Sum"].GetDouble(); } }