/// <summary> /// Processes the specified MetadataPropertyCollectionUpdate. /// </summary> /// <param name="metadataPropertyCollectionUpdate">The MetadataPropertyCollectionUpdate.</param> /// <returns><c>true</c> if MetadataPropertyCollectionUpdate is processed successfully; otherwise, <c>false</c></returns> internal bool Process(MetadataPropertyCollectionUpdate metadataPropertyCollectionUpdate) { try { //Process Deletes if (metadataPropertyCollectionUpdate.DeleteIndexPropertyCollection != null && metadataPropertyCollectionUpdate.DeleteIndexPropertyCollection.Count > 0 && Count > 0) { foreach (string propertyName in metadataPropertyCollectionUpdate.DeleteIndexPropertyCollection) { Remove(propertyName); } } //Process Adds if (metadataPropertyCollectionUpdate.AddIndexPropertyCollection != null && metadataPropertyCollectionUpdate.AddIndexPropertyCollection.Count > 0) { foreach (var kvp in metadataPropertyCollectionUpdate.AddIndexPropertyCollection) { this[kvp.Key] = kvp.Value; } } } catch (Exception ex) { throw new Exception("Error processing MetadataPropertyCollectionUpdate.", ex); } return(true); }
/// <summary> /// Deserializes the specified reader. /// </summary> /// <param name="reader">The reader.</param> /// <param name="version">The version.</param> public override void Deserialize(IPrimitiveReader reader, int version) { using (reader.CreateRegion()) { //IndexId ushort len = reader.ReadUInt16(); if (len > 0) { IndexId = reader.ReadBytes(len); } //TargetIndexName TargetIndexName = reader.ReadString(); //MetadataPropertyCollectionUpdate if (reader.ReadBoolean()) { MetadataPropertyCollectionUpdate = new MetadataPropertyCollectionUpdate(); Serializer.Deserialize(reader.BaseStream, MetadataPropertyCollectionUpdate); } } }
public void Deserialize(IPrimitiveReader reader, int version) { //IndexId ushort len = reader.ReadUInt16(); if (len > 0) { IndexId = reader.ReadBytes(len); } //TargetIndexName TargetIndexName = reader.ReadString(); //IndexTagMapping ushort count = reader.ReadUInt16(); IndexTagMapping = new Dictionary <string, List <string> >(count); if (count > 0) { string indexName; ushort tagNameListCount; List <string> tagNameList; for (ushort i = 0; i < count; i++) { indexName = reader.ReadString(); tagNameListCount = reader.ReadUInt16(); tagNameList = new List <string>(); for (ushort j = 0; j < tagNameListCount; j++) { tagNameList.Add(reader.ReadString()); } IndexTagMapping.Add(indexName, tagNameList); } } //AddList AddList = DeserializeIndexDataItemList(reader); //DeleteList int listCount = reader.ReadInt32(); DeleteList = new List <IndexItem>(listCount); IndexItem indexItem; for (int i = 0; i < listCount; i++) { indexItem = new IndexItem(); indexItem.Deserialize(reader); DeleteList.Add(indexItem); } //Metadata len = reader.ReadUInt16(); if (len > 0) { Metadata = reader.ReadBytes(len); } //UpdateMetadata UpdateMetadata = reader.ReadBoolean(); //ReplaceFullIndex ReplaceFullIndex = reader.ReadBoolean(); if (version >= 2) { //PreserveData PreserveData = reader.ReadBoolean(); } if (version >= 3) { //IndexVirtualCountMapping count = reader.ReadUInt16(); if (count > 0) { IndexVirtualCountMapping = new Dictionary <string, int>(count); string indexName; int virtualCount; for (ushort i = 0; i < count; i++) { indexName = reader.ReadString(); virtualCount = reader.ReadInt32(); IndexVirtualCountMapping.Add(indexName, virtualCount); } } } if (version >= 4) { //PrimaryId primaryId = reader.ReadInt32(); } if (version >= 5) { //MetadataPropertyCollectionUpdate if (reader.ReadBoolean()) { MetadataPropertyCollectionUpdate = new MetadataPropertyCollectionUpdate(); Serializer.Deserialize(reader.BaseStream, MetadataPropertyCollectionUpdate); } } if (version >= 6) { //UpdateList UpdateList = DeserializeIndexDataItemList(reader); } }