/// <summary> /// Write a single state provider metadata to the stream. /// </summary> /// <param name="writer">Stream to write to.</param> /// <param name="metadata">State provider metadata to serialize.</param> /// <returns>The record size written.</returns> private static int WriteMetadata(InMemoryBinaryWriter writer, SerializableMetadata metadata) { var startPosition = writer.BaseStream.Position; // Reserve an 'int' for the record size at the beginning. writer.BaseStream.Position += sizeof(int); // Serialize the metadata. writer.Write(metadata.Name); writer.Write(metadata.Type); writer.Write(metadata.CreateLsn); writer.Write(metadata.DeleteLsn); writer.WriteNullable(metadata.InitializationContext); writer.Write((int)metadata.MetadataMode); writer.Write(metadata.StateProviderId); writer.Write(metadata.ParentStateProviderId); // Get the size of the record. var endPosition = writer.BaseStream.Position; var recordSize = checked ((int)(endPosition - startPosition)); // Write the record size at the start of the block. writer.BaseStream.Position = startPosition; writer.Write(recordSize); // Restore the end position. writer.BaseStream.Position = endPosition; return(recordSize); }
public static void SerializeRedoData( ReplicationMetadata replicationMetadata, string traceType, InMemoryBinaryWriter writer) { try { writer.Write(replicationMetadata.Type); writer.WriteNullable(replicationMetadata.InitializationContext); writer.Write(replicationMetadata.ParentStateProviderId); } catch (Exception e) { StateManagerStructuredEvents.TraceException(traceType, "ReplicationMetadata.Serialize", string.Empty, e); throw; } }