private ITrwSerializationWriteContext BasicWriteContext(ITrwWriter writer, bool aliasTypes) { var serializationType = SaveLoadConstants.BasicSerializationType; var handlers = serializationNecessities.GetTrwHandlerContainer(serializationType); var typeRedirects = serializationNecessities.GetTrwHandlerTypeRedirects(serializationType); return(new TrwSerializationWriteContext(writer, handlers, typeRedirects, new TrwSerializationOptions { ExplicitTypes = TrwSerializationExplicitTypes.Never, AliasTypes = aliasTypes })); }
public void SaveConfig <T>() where T : class, IConfig, new() { var config = (T)configs.GetOrAdd(typeof(T), x => new T()); var handlerContainer = serializationNecessities.GetTrwHandlerContainer(ConfigSerializationNecessitiesProvider.SerializationType); var typeRedirects = serializationNecessities.GetTrwHandlerTypeRedirects(ConfigSerializationNecessitiesProvider.SerializationType); var options = new TrwSerializationOptions { ExplicitTypes = TrwSerializationExplicitTypes.Never }; using (var fileStream = fileStorage.FileSystem.OpenWriteNew(GetFileName <T>())) using (var trwReader = trwFactory.JsonWriter(fileStream)) using (var context = new TrwSerializationWriteContext(trwReader, handlerContainer, typeRedirects, options)) context.Write <T>(config); }
public UndoRedoService(IWorldTreeService worldTreeService, IAssetService assetService, ISerializationNecessities serializationNecessities, ITrwDiffBuilder diffBuilder) { this.worldTreeService = worldTreeService; this.diffBuilder = diffBuilder; var handlers = serializationNecessities.GetTrwHandlerContainer(SaveLoadConstants.WorldSerializationType); var typeRedirects = serializationNecessities.GetTrwHandlerTypeRedirects(SaveLoadConstants.WorldSerializationType); diffApplier = new TrwSerializationDiffApplier(handlers, typeRedirects, x => x.Add(SaveLoadConstants.AssetDictBagKey, new Dictionary <string, IAsset>()), x => x.Add(SaveLoadConstants.AssetDictBagKey, assetService.Assets)); diffIdentityComparer = new UndoRedoDiffIdentityComparer(); undoStack = new Stack <IUndoable>(); redoStack = new Stack <IUndoable>(); guiObserver = null; }