/// <summary> /// Deserialize the class data from a stream. /// </summary> /// <param name="reader">The <see cref="T:MySpace.Common.IO.IPrimitiveReader"/> that extracts used to extra data from a stream.</param> /// <param name="version">The value of <see cref="P:MySpace.Common.IVersionSerializable.CurrentVersion"/> that was written to the stream when it was originally serialized to a stream; /// the version of the <paramref name="reader"/> data.</param> public void Deserialize(IPrimitiveReader reader, int version) { using (reader.CreateRegion()) { //KeyBagMapping ushort count = reader.ReadUInt16(); if (count > 0) { ResultItemBag resultItemBag = null; byte[] compositeKey; ushort len; KeyBagMapping = new Dictionary <byte[], ResultItemBag>(new ByteArrayEqualityComparer()); for (int i = 0; i < count; i++) { len = reader.ReadUInt16(); if (len > 0) { //CompositeKey compositeKey = reader.ReadBytes(len); //ResultItemBag if (reader.ReadBoolean()) { resultItemBag = new ResultItemBag(BaseComparer, compositeKey); Serializer.Deserialize(reader.BaseStream, resultItemBag); } KeyBagMapping.Add(compositeKey, resultItemBag); SortedResultItemBagList.Add(resultItemBag); } } } } }
public void Remove(ResultItemBag resultItemBag) { // remove based on obj reference for (int i = 0; i < SortedBag.Count; i++) { if (SortedBag[i] == resultItemBag) { SortedBag.RemoveAt(i); break; } } }
public void Add(ResultItemBag resultItemBag) { // add based on sort order int pos = SortedBag.BinarySearch(resultItemBag, BaseComparer); if (pos < 0) { pos = ~pos; } SortedBag.Insert(pos, resultItemBag); }
public bool Add(byte[] compositeKey, ResultItem resultItem) { bool retVal = false; ResultItemBag resultItemBag; if (KeyBagMapping.TryGetValue(compositeKey, out resultItemBag)) { SortedResultItemBagList.Remove(resultItemBag); resultItemBag.Add(resultItem); retVal = true; } else { resultItemBag = new ResultItemBag(BaseComparer, compositeKey); resultItemBag.Add(resultItem); KeyBagMapping.Add(compositeKey, resultItemBag); } SortedResultItemBagList.Add(resultItemBag); return(retVal); }
public bool Add(byte[] compositeKey, ResultItemBag resultItemBag) { bool retVal = false; ResultItemBag storedResultItemBag; if (KeyBagMapping.TryGetValue(compositeKey, out storedResultItemBag)) { SortedResultItemBagList.Remove(storedResultItemBag); foreach (ResultItem resultItem in resultItemBag) { storedResultItemBag.Add(resultItem); } SortedResultItemBagList.Add(storedResultItemBag); retVal = true; } else { KeyBagMapping.Add(compositeKey, resultItemBag); SortedResultItemBagList.Add(resultItemBag); } return(retVal); }