Ejemplo n.º 1
0
        public void Commit()
        {
            if (this.initialized == false)
            {
                return;
            }

            DirectoryUtility.Backup(this.BasePath);

            DirectoryUtility.Prepare(this.BasePath);
            foreach (var item in this.tableInfos)
            {
                using (var stream = FileUtility.OpenWrite(this.BasePath, CremaSchema.TableDirectory, infoDirectory, item.Key + jsonExtension))
                {
                    JsonSerializerUtility.Write(stream, item.Value);
                }
            }
            foreach (var item in this.tableDatas)
            {
                using (var stream = FileUtility.OpenWrite(this.BasePath, CremaSchema.TableDirectory, dataDirectory, item.Key))
                {
                    this.OnSerializeTable(stream, item.Value);
                }
            }

            foreach (var item in this.typeInfos)
            {
                using (var stream = FileUtility.OpenWrite(this.BasePath, CremaSchema.TypeDirectory, infoDirectory, item.Key + jsonExtension))
                {
                    JsonSerializerUtility.Write(stream, item.Value);
                }
            }
            foreach (var item in this.typeDatas)
            {
                using (var stream = FileUtility.OpenWrite(this.BasePath, CremaSchema.TypeDirectory, dataDirectory, item.Key))
                {
                    this.OnSerializeTable(stream, item.Value);
                }
            }

            var tableInfos = this.tableInfos.Select(item => Path.Combine(CremaSchema.TableDirectory, item.Key));
            var typeInfos  = this.typeInfos.Select(item => Path.Combine(CremaSchema.TypeDirectory, item.Key));

            this.info.ItemList = tableInfos.Concat(typeInfos).ToArray();
            this.info.Version  = new Version(CremaSchema.MajorVersion, CremaSchema.MinorVersion);
            this.WriteInfo();
            DirectoryUtility.Clean(this.BasePath);
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     foreach (var item in this.ToArray <DataBase>())
     {
         {
             var dataBaseInfo = (DataBaseSerializationInfo)item.DataBaseInfo;
             var filename     = FileUtility.Prepare(this.cachePath, $"{item.ID}{databaseExtension}");
             JsonSerializerUtility.Write(filename, dataBaseInfo, true);
         }
         {
             var dataBaseState = item.DataBaseState & DataBaseState.IsLoaded;
             var filename      = FileUtility.Prepare(this.cachePath, $"{item.ID}{stateExtension}");
             JsonSerializerUtility.Write(filename, dataBaseState, true);
         }
         item.Dispose();
     }
 }
Ejemplo n.º 3
0
        private void WriteInfo()
        {
            var infoPath = Path.Combine(this.BasePath, "info.json");

            JsonSerializerUtility.Write(infoPath, this.info, true);
        }
Ejemplo n.º 4
0
 private static void WriteAccessInfo(string accessInfoPath, AccessInfo accessInfo)
 {
     JsonSerializerUtility.Write(accessInfoPath, (AccessSerializationInfo)accessInfo, true);
 }