コード例 #1
0
 public static SerializationTableResponse ConvertFrom(SerializationTable serializationTable)
 {
     return(new SerializationTableResponse
     {
         Tags = serializationTable.Tags,
         DerivedTags = serializationTable.DerivedTags,
         HashValue = serializationTable.HashValue,
         Name = serializationTable.Name,
         TableName = serializationTable.TableName,
         TemplatedParent = serializationTable.TemplatedParent,
         Parent = serializationTable.Parent,
         Comment = serializationTable.Comment,
         Revision = serializationTable.Revision,
         CategoryPath = serializationTable.CategoryPath,
         Columns = serializationTable.Columns.Select(SerializationColumnResponse.ConvertFrom).ToArray(),
         Rows = serializationTable.Rows.Select(SerializationRowResponse.ConvertFrom).ToArray()
     });
 }
コード例 #2
0
        private void SerializeTable(Stream stream, SerializationTable dataTable, SerializationType[] types)
        {
            var columns = dataTable.Columns;
            var rows    = dataTable.Rows;

            this.tableHeader.MagicValue = (int)dataTable.Revision;
            this.tableHeader.HashValue  = this.GetStringID(dataTable.HashValue);

            this.tableInfo.TableName    = this.GetStringID(dataTable.Name);
            this.tableInfo.CategoryName = this.GetStringID(dataTable.CategoryPath);
            this.tableInfo.ColumnsCount = columns.Length;
            this.tableInfo.RowsCount    = rows.Length;

            this.CollectColumns(columns);

            var writer = new BinaryWriter(stream);

            writer.WriteValue(this.tableHeader);

            this.tableHeader.TableInfoOffset = writer.GetPosition();
            writer.WriteValue(this.tableInfo);
            this.tableHeader.ColumnsOffset = writer.GetPosition();

            writer.WriteArray(this.columns.ToArray());

            this.tableHeader.RowsOffset = writer.GetPosition();
            this.WriteRows(writer, rows, columns, types);

            this.tableHeader.StringResourcesOffset = writer.GetPosition();
            writer.WriteResourceStrings(this.strings.ToArray());

            this.tableHeader.UserOffset = writer.GetPosition();
            writer.Write((byte)0);

            var lastPosition = writer.GetPosition();

            writer.Seek(0, SeekOrigin.Begin);
            writer.WriteValue(this.tableHeader);
            writer.Seek((int)this.tableHeader.TableInfoOffset, SeekOrigin.Begin);
            writer.WriteValue(this.tableInfo);
            writer.SetPosition(lastPosition);
        }