public static Message Deserialize(BinaryReader reader) { int structType = reader.ReadInt32(); int pathCount = reader.ReadInt32(); string[] path = new string[pathCount]; for (int i = 0; i < pathCount; i++) { int sizeOfString = reader.ReadInt32(); byte[] pathNameBytes = reader.ReadBytes(sizeOfString); path[i] = Encoding.Unicode.GetString(pathNameBytes); } KeyDescriptor keyDescriptor = KeyDescriptor.Deserialize(reader); RecordDescriptor recordDescriptor = RecordDescriptor.Deserialize(reader); ILocator locator = STSdb4.Database.Locator.Obtain(structType, keyDescriptor, recordDescriptor, path); IndexPersistOperationCollection persistOperations = new IndexPersistOperationCollection(locator); IOperationCollection operations = persistOperations.Read(reader); return(new Message(operations)); }
/// <summary> /// Build: /// - Apply /// - PersistDataContainer /// - PersistOperations /// - PersistKey /// - KeyComparer /// - KeyEqualityComparer /// /// instances from StructType, keySlotTypes & recordSlotTypes /// </summary> protected virtual void BuildMembers() { //apply switch (StructureType) { case STSdb4.Database.StructureType.XINDEX: Apply = new XIndexApply(this); break; case STSdb4.Database.StructureType.XFILE: Apply = new XStreamApply(this); break; } //comparer & equality comparer KeyComparer = new DataComparer(KeyDescriptor.DataType, KeyDescriptor.CompareOptions); KeyEqualityComparer = new DataEqualityComparer(KeyDescriptor.DataType, KeyDescriptor.CompareOptions); bool compressKeys = KeyDescriptor.CompressData; bool compressRecords = RecordDescriptor.CompressData; if (compressKeys || compressRecords) { PersistDataContainer = new IndexPersistDataContainer(this, KeyDescriptor.DataType, RecordDescriptor.DataType, compressKeys, compressRecords); } else { PersistDataContainer = new IndexPersistDataContainerRaw(this, KeyDescriptor.DataType, RecordDescriptor.DataType); } PersistOperations = new IndexPersistOperationCollection(this); PersistKey = new DataPersist(KeyDescriptor.DataType); }
public void Serialize(BinaryWriter writer) { Locator locator = (Locator)Operations.Locator; writer.Write(locator.StructureType); writer.Write(locator.Length); for (int i = 0; i < locator.Length; i++) { byte[] pathNameBytes = Encoding.Unicode.GetBytes(locator[i]); writer.Write(pathNameBytes.Length); writer.Write(pathNameBytes); } locator.KeyDescriptor.Serialize(writer); locator.RecordDescriptor.Serialize(writer); IndexPersistOperationCollection operationPersist = new IndexPersistOperationCollection(locator); operationPersist.Write(writer, Operations); }