public void Save(string outputFile) { string?directory; if (File.Exists(outputFile) && File.GetAttributes(outputFile).HasFlag(FileAttributes.Directory)) { directory = outputFile; } else { directory = Path.GetDirectoryName(outputFile); } if (directory == null) { return; } EngineSerializer engineSerializer = new EngineSerializer(); engineSerializer.Save(this, directory); GameplaySerializer gameplaySerializer = new GameplaySerializer(); gameplaySerializer.Save(this, directory); for (int i = 0; i < terrainChunks.Count; i++) { ChunkSerializer chunkSerializer = new ChunkSerializer(); chunkSerializer.Save(this, directory, i); } }
/// <summary> /// Pre-emptively attempts to handle failures of <see cref="ExceptionRootCause.Unknown"/> by logging and removing /// the engine state that is persisted build-over-build. /// </summary> /// <remarks> /// This is done at the end of the build during <see cref="MarkFailure(Exception)"/>, since there is no reason /// to defer it to <see cref="Recover"/> which runs at the beginning of the next build. /// </remarks> public override Possible <Unit> MarkFailure([NotNull] Exception exception) { Logger.Log.LogAndRemoveEngineStateOnCatastrophicFailure(m_loggingContext); if (EngineSerializer.TryLogAndRemoveCorruptEngineState(Configuration, PathTable, m_loggingContext)) { return(Unit.Void); } return(new Failure <string>("Error logging and removing engine state while handling catastrophic failure.")); }
private void mapSaveAsBtn_Click(object sender, EventArgs e) { if (mapSaveDialog.ShowDialog() == DialogResult.OK) { string pathName = Path.GetDirectoryName(mapSaveDialog.FileName); GameplaySerializer gameplaySerializer = new GameplaySerializer(); gameplaySerializer.Save(level, mapSaveDialog.FileName); EngineSerializer engineSerializer = new EngineSerializer(); engineSerializer.Save(level, pathName); } InvalidateView(); }
/// <summary> /// Serializes and saves state needed for execution analyzers. /// </summary> private Task <bool> SaveExecutionStateToDiskAsync(ScheduleRunResult result) { // Every scheduler run has a unique log directory based off timestamp of run string logDirectory = Path.Combine( result.Config.Logging.LogsDirectory.ToString(Context.PathTable), result.Config.Logging.LogPrefix); var serializer = new EngineSerializer( LoggingContext, logDirectory, correlationId: FileEnvelopeId.Create()); var dummyHistoricData = (IReadOnlyList <HistoricDataPoint>)CollectionUtilities.EmptyArray <HistoricDataPoint>(); var dummyHistoricTableSizes = new HistoricTableSizes(dummyHistoricData); return(EngineSchedule.SaveExecutionStateToDiskAsync( serializer, Context, PipTable, result.Graph, Expander, dummyHistoricTableSizes)); }