예제 #1
0
        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
            }));
        }
예제 #2
0
        private T LoadConfig <T>() where T : class, IConfig, new()
        {
            var handlerContainer = serializationNecessities.GetTrwHandlerContainer(ConfigSerializationNecessitiesProvider.SerializationType);
            var options          = new TrwSerializationOptions
            {
                ExplicitTypes = TrwSerializationExplicitTypes.Never
            };

            using (var fileStream = fileStorage.FileSystem.OpenRead(GetFileName <T>()))
                using (var trwReader = trwFactory.JsonReader(fileStream))
                    using (var context = new TrwSerializationReadContext(trwReader, handlerContainer, null, options))
                        return(context.Read <T>());
        }
예제 #3
0
        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;
        }