Beispiel #1
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            using (reader.CreateRegion())
            {
                //InclusiveMaxValue
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    InclusiveMaxValue = reader.ReadBytes(len);
                }

                //InclusiveMinvalue
                len = reader.ReadUInt16();
                if (len > 0)
                {
                    InclusiveMinValue = reader.ReadBytes(len);
                }

                if (version >= 2)
                {
                    //InclusiveMaxMetadataProperty
                    InclusiveMaxMetadataProperty = reader.ReadString();

                    //InclusiveMaxMetadataPropertyDataType
                    InclusiveMaxMetadataPropertyDataType = (DataType)reader.ReadByte();

                    //InclusiveMinMetadataProperty
                    InclusiveMinMetadataProperty = reader.ReadString();

                    //InclusiveMinMetadataPropertyDataType
                    InclusiveMinMetadataPropertyDataType = (DataType)reader.ReadByte();
                }
            }
        }
        public virtual void Deserialize(IPrimitiveReader reader)
        {
            //ItemId
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                itemId = reader.ReadBytes(len);
            }

            //Tags
            ushort count = reader.ReadUInt16();

            tags = new Dictionary <string, byte[]>(count);
            if (count > 0)
            {
                string tagName;
                byte[] tagValue;
                ushort tagValueLen;

                for (ushort i = 0; i < count; i++)
                {
                    tagName     = reader.ReadString();
                    tagValueLen = reader.ReadUInt16();
                    tagValue    = null;
                    if (tagValueLen > 0)
                    {
                        tagValue = reader.ReadBytes(tagValueLen);
                    }
                    tags.Add(tagName, tagValue);
                }
            }
        }
Beispiel #3
0
        public void Deserialize(IPrimitiveReader reader)
        {
            this.pageSize         = reader.ReadInt32();
            this.minValidDateTime = new DateTime(reader.ReadInt64());

            #region cacheTypeCaps
            int count = reader.ReadInt32();
            if (count > 0)
            {
                this.cacheTypeCaps = new Dictionary <int, int>(count);
                for (int i = 0; i < count; i++)
                {
                    this.cacheTypeCaps[reader.ReadInt32()] = reader.ReadInt32();
                }
            }
            #endregion

            #region queryList
            count = reader.ReadInt32();
            if (count > 0)
            {
                this.queryList = new List <Pair <List <byte[]>, List <int> > >(count);
                List <byte[]> IndexIdList   = null;
                List <int>    CacheTypeList = null;

                // IndexId Length in bytes
                int IndexIdLen = reader.ReadInt32();
                int IndexIdListLen;
                int CacheTypeListLen;
                for (int j = 0; j < count; j++)
                {
                    #region  IndexIdList
                    IndexIdListLen = reader.ReadInt32();
                    if (IndexIdListLen > 0)
                    {
                        IndexIdList = new List <byte[]>(IndexIdListLen);
                        for (int k = 0; k < IndexIdListLen; k++)
                        {
                            IndexIdList.Add(reader.ReadBytes(IndexIdLen));
                        }
                    }
                    #endregion

                    #region CacheTypeList
                    CacheTypeListLen = reader.ReadInt32();
                    if (CacheTypeListLen > 0)
                    {
                        CacheTypeList = new List <int>(CacheTypeListLen);
                        for (int l = 0; l < CacheTypeListLen; l++)
                        {
                            CacheTypeList.Add(reader.ReadInt32());
                        }
                    }
                    #endregion

                    this.queryList.Add(new Pair <List <byte[]>, List <int> >(IndexIdList, CacheTypeList));
                }
            }
            #endregion
        }
Beispiel #4
0
        /// <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 Deserialize(IPrimitiveReader reader, int version)
        {
            //MultiItemResult
            if (reader.ReadByte() != 0)
            {
                multiItemResult = new MultiItemResult();
                multiItemResult.Deserialize(reader);
            }

            //Metadata
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                metadata = reader.ReadBytes(len);
            }

            //IndexSize
            indexSize = reader.ReadInt32();

            //IndexExists
            indexExists = reader.ReadBoolean();

            //ExceptionInfo
            exceptionInfo = reader.ReadString();

            //VirtualCount
            if (version >= 2)
            {
                virtualCount = reader.ReadInt32();
            }
        }
Beispiel #6
0
        /// <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())
            {
                //FieldValue
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    FieldValue = reader.ReadBytes(len);
                }
                else
                {
                    new LogWrapper().Error("FieldValue in FilterCaps cannot be null or zero length byte array");
                    throw new Exception("FieldValue in FilterCaps cannot be null or zero length byte array");
                }

                //UseParentFilter
                UseParentFilter = reader.ReadBoolean();

                //Filter
                byte b = reader.ReadByte();
                if (b != 0)
                {
                    Filter = FilterFactory.CreateFilter(reader, (FilterType)b);
                }

                //Cap
                Cap = reader.ReadInt32();
            }
        }
        public void Deserialize(IPrimitiveReader reader)
        {
            this.pageSize         = reader.ReadInt32();
            this.pageNum          = reader.ReadInt32();
            this.minValidDateTime = new DateTime(reader.ReadInt64());
            int count = reader.ReadInt32();

            indexIdList = new List <byte[]>(count);
            if (count > 0)
            {
                int keyLen = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    indexIdList.Add(reader.ReadBytes(keyLen));
                }
            }
            count         = reader.ReadInt32();
            cacheTypeList = new List <int>(count);
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    cacheTypeList.Add(reader.ReadInt32());
                }
            }
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexExists
            IndexExists = reader.ReadBoolean();

            //DistinctValueCountPairList
            int listCount = reader.ReadInt32();

            DistinctValueCountMapping = new Dictionary <byte[], int>(listCount, new ByteArrayEqualityComparer());
            if (listCount > 0)
            {
                for (int i = 0; i < listCount; i++)
                {
                    //Value
                    ushort len = reader.ReadUInt16();
                    if (len > 0)
                    {
                        DistinctValueCountMapping.Add(reader.ReadBytes(len), reader.ReadInt32());
                    }
                }
            }

            //ExceptionInfo
            ExceptionInfo = reader.ReadString();
        }
Beispiel #9
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexId
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                IndexId = reader.ReadBytes(len);
            }

            //FieldName
            FieldName = reader.ReadString();

            //ItemsToLookUp
            ItemsToLookUp = reader.ReadNullableInt32();

            //TargetIndexName
            TargetIndexName = reader.ReadString();

            //IndexCondition
            if (reader.ReadBoolean())
            {
                IndexCondition = new IndexCondition();
                Serializer.Deserialize(reader.BaseStream, IndexCondition);
            }
        }
        /// <summary>
        /// Deserializes the internal item.
        /// </summary>
        /// <param name="itemId">The item id.</param>
        /// <param name="inDeserializationContext">The in deserialization context.</param>
        /// <param name="reader">The reader.</param>
        /// <returns>InternalItem</returns>
        private static InternalItem DeserializeInternalItem(byte[] itemId, InDeserializationContext inDeserializationContext, IPrimitiveReader reader)
        {
            byte kvpListCount = reader.ReadByte();

            List <KeyValuePair <int, byte[]> > kvpList = null;

            if (kvpListCount > 0)
            {
                kvpList = new List <KeyValuePair <int, byte[]> >(kvpListCount);
                for (byte j = 0; j < kvpListCount; j++)
                {
                    int    tagHashCode = reader.ReadInt32();
                    ushort tagValueLen = reader.ReadUInt16();
                    byte[] tagValue    = null;
                    if (tagValueLen > 0)
                    {
                        tagValue = reader.ReadBytes(tagValueLen);
                        if (inDeserializationContext.StringHashCodeDictionary != null &&
                            inDeserializationContext.StringHashCodeDictionary.Count > 0 &&
                            inDeserializationContext.StringHashCodeDictionary.ContainsKey(tagHashCode))
                        {
                            tagValue =
                                inDeserializationContext.StringHashCollection.GetStringByteArray(
                                    inDeserializationContext.TypeId, tagValue);
                        }
                    }
                    kvpList.Add(new KeyValuePair <int, byte[]>(tagHashCode, tagValue));
                }
            }
            return(new InternalItem {
                ItemId = itemId, TagList = kvpList
            });
        }
Beispiel #11
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexDataItem List
            ushort count = reader.ReadUInt16();

            if (count > 0)
            {
                IndexDataItem indexDataItem;
                for (ushort i = 0; i < count; i++)
                {
                    if (reader.ReadBoolean())
                    {
                        indexDataItem = new IndexDataItem();
                        Serializer.Deserialize(reader.BaseStream, indexDataItem);
                        Add(indexDataItem);
                    }
                }

                //IndexId
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    IndexId = reader.ReadBytes(len);
                }

                //IndexSize
                IndexSize = reader.ReadInt32();

                //IndexExists
                IndexExists = reader.ReadBoolean();

                //IndexCap
                IndexCap = reader.ReadInt32();
            }
        }
        /// <summary>
        /// Skips the deserialization of the internal item.
        /// </summary>
        /// <param name="reader">The reader.</param>
        private static void SkipDeserializeInternalItem(IPrimitiveReader reader)
        {
            var kvpListCount = reader.ReadByte();

            //kvpList
            if (kvpListCount > 0)
            {
                for (byte j = 0; j < kvpListCount; j++)
                {
                    //tagHashCode
                    reader.ReadBytes(4);

                    //tagValueLen + value
                    reader.ReadBytes(reader.ReadUInt16());
                }
            }
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexExists
            IndexExists = reader.ReadBoolean();

            //IndexSize
            IndexSize = reader.ReadInt32();

            //Metadata
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                Metadata = reader.ReadBytes(len);
            }

            //ResultItemList
            int listCount = reader.ReadInt32();

            ResultItemList = new List <ResultItem>(listCount);
            if (listCount > 0)
            {
                ResultItem resultItem;
                for (int i = 0; i < listCount; i++)
                {
                    resultItem = new ResultItem();
                    resultItem.Deserialize(reader);
                    ResultItemList.Add(resultItem);
                }
            }

            //ExceptionInfo
            ExceptionInfo = reader.ReadString();

            //VirtualCount
            if (version >= 2)
            {
                VirtualCount = reader.ReadInt32();
            }

            //IndexCap
            if (version >= 3)
            {
                IndexCap = reader.ReadInt32();
            }

            if (version >= 4)
            {
                //MetadataPropertyCollection
                if (reader.ReadBoolean())
                {
                    MetadataPropertyCollection = new MetadataPropertyCollection();
                    Serializer.Deserialize(reader.BaseStream, MetadataPropertyCollection);
                }
            }
        }
Beispiel #14
0
        /// <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())
            {
                //FieldName
                FieldName = reader.ReadString();

                //IsTag
                IsTag = reader.ReadBoolean();

                //Operation
                Operation = (Operation)reader.ReadByte();

                //Value
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    Value = reader.ReadBytes(len);
                }

                //DataType
                DataType = (DataType)reader.ReadByte();

                if (version >= 2)
                {
                    //MatchValue
                    len = reader.ReadUInt16();
                    if (len > 0)
                    {
                        ExpectedBitwiseResult = reader.ReadBytes(len);
                    }

                    //ShiftBy
                    ShiftBy = reader.ReadByte();
                }

                if (version >= 3)
                {
                    //MetadataProperty
                    MetadataProperty = reader.ReadString();
                }
            }
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            using (reader.CreateRegion())
            {
                //InclusiveMaxValue
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    InclusiveMaxValue = reader.ReadBytes(len);
                }

                //InclusiveMinvalue
                len = reader.ReadUInt16();
                if (len > 0)
                {
                    InclusiveMinValue = reader.ReadBytes(len);
                }
            }
        }
        /// <summary>
        /// Deserializes the internal item.
        /// </summary>
        /// <param name="internalItem">The internal item</param>
        /// <param name="inDeserializationContext">The in deserialization context.</param>
        /// <param name="outDeserializationContext">The out deserialization context.</param>
        /// <param name="reader">The reader.</param>
        private static void DeserializeTags(InternalItem internalItem,
                                            InDeserializationContext inDeserializationContext,
                                            OutDeserializationContext outDeserializationContext,
                                            IPrimitiveReader reader)
        {
            byte kvpListCount = reader.ReadByte();

            if (kvpListCount > 0)
            {
                internalItem.TagList = new List <KeyValuePair <int, byte[]> >(kvpListCount);
                for (byte j = 0; j < kvpListCount; j++)
                {
                    int    tagHashCode = reader.ReadInt32();
                    ushort tagValueLen = reader.ReadUInt16();
                    byte[] tagValue    = null;
                    if (tagValueLen > 0)
                    {
                        tagValue = reader.ReadBytes(tagValueLen);
                        if (inDeserializationContext.StringHashCodeDictionary != null &&
                            inDeserializationContext.StringHashCodeDictionary.Count > 0 &&
                            inDeserializationContext.StringHashCodeDictionary.ContainsKey(tagHashCode))
                        {
                            tagValue = inDeserializationContext.StringHashCollection.GetStringByteArray(inDeserializationContext.TypeId, tagValue);
                        }
                    }
                    internalItem.TagList.Add(new KeyValuePair <int, byte[]>(tagHashCode, tagValue));
                }
            }

            //Get Distinct Values
            if (!String.IsNullOrEmpty(inDeserializationContext.GetDistinctValuesFieldName))
            {
                byte[] distinctValue;
                if (String.Equals(inDeserializationContext.GetDistinctValuesFieldName, "ItemId", StringComparison.OrdinalIgnoreCase))
                {
                    distinctValue = internalItem.ItemId;
                }
                else
                {
                    internalItem.TryGetTagValue(inDeserializationContext.GetDistinctValuesFieldName, out distinctValue);
                }

                if (distinctValue != null)
                {
                    if (outDeserializationContext.DistinctValueCountMapping.ContainsKey(distinctValue))
                    {
                        outDeserializationContext.DistinctValueCountMapping[distinctValue] += 1;
                    }
                    else
                    {
                        outDeserializationContext.DistinctValueCountMapping.Add(distinctValue, 1);
                    }
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Deserializes a <see cref="RelayPayload"/> from an <see cref="IPrimitiveReader"/>.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="version">The version of the <paramref name="reader"/> data.</param>
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            this.TypeId           = reader.ReadInt16();
            this.Id               = reader.ReadInt32();
            this.LastUpdatedTicks = reader.ReadInt64();
            this.Compressed       = reader.ReadBoolean();
            this.ttl              = reader.ReadInt32();
            this.expirationTicks  = reader.ReadInt64();
            int byteLength = reader.ReadInt32();

            if (byteLength > 0)
            {
                this.ByteArray = reader.ReadBytes(byteLength);
            }
            if (version > 1)
            {
                int keyLength = reader.ReadInt32();
                this.ExtendedId = reader.ReadBytes(keyLength);
            }
        }
		public override void Deserialize(IPrimitiveReader reader)
		{
			base.Deserialize(reader);

			//IndexId
			ushort len = reader.ReadUInt16();
			if (len > 0)
			{
				indexId = reader.ReadBytes(len);
			}
		}
        public override void Deserialize(IPrimitiveReader reader)
        {
            base.Deserialize(reader);

            //IndexId
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                indexId = reader.ReadBytes(len);
            }
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //Metadata
            ushort len = reader.ReadUInt16();
            if (len > 0)
            {
                metadata = reader.ReadBytes(len);
            }

            //VirtualCount
            virtualCount = reader.ReadInt32();
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexId
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                indexId = reader.ReadBytes(len);
            }

            //IndexItemList
            ushort count = reader.ReadUInt16();

            if (count > 0)
            {
                IndexItem indexItem;
                indexItemList = new List <IndexItem>(count);
                for (ushort i = 0; i < count; i++)
                {
                    indexItem = new IndexItem();
                    indexItem.Deserialize(reader);
                    indexItemList.Add(indexItem);
                }
            }

            //TargetIndexName
            targetIndexName = reader.ReadString();

            //TagsFromIndexes
            count           = reader.ReadUInt16();
            tagsFromIndexes = new List <string>(count);
            if (count > 0)
            {
                for (ushort i = 0; i < count; i++)
                {
                    tagsFromIndexes.Add(reader.ReadString());
                }
            }

            //ExcludeData
            excludeData = reader.ReadBoolean();

            //GetMetadata
            getMetadata = reader.ReadBoolean();

            if (version >= 2)
            {
                //FullDataIdInfo
                fullDataIdInfo = new FullDataIdInfo();
                Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
            }
        }
Beispiel #22
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            using (reader.CreateRegion())
            {
                //IndexId
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    IndexId = reader.ReadBytes(len);
                }

                //Count
                Count = reader.ReadInt32();

                //TargetIndexName
                TargetIndexName = reader.ReadString();

                //ExcludeData
                ExcludeData = reader.ReadBoolean();

                //GetMetadata
                GetMetadata = reader.ReadBoolean();

                //Filter
                byte b = reader.ReadByte();
                if (b != 0)
                {
                    FilterType filterType = (FilterType)b;
                    Filter = FilterFactory.CreateFilter(reader, filterType);
                }

                //FullDataIdInfo
                if (reader.ReadBoolean())
                {
                    FullDataIdInfo = new FullDataIdInfo();
                    Serializer.Deserialize(reader.BaseStream, FullDataIdInfo);
                }

                //IndexCondition
                if (reader.ReadBoolean())
                {
                    IndexCondition = new IndexCondition();
                    Serializer.Deserialize(reader.BaseStream, IndexCondition);
                }

                if (version >= 2)
                {
                    //DomainSpecificProcessingType
                    DomainSpecificProcessingType = (DomainSpecificProcessingType)reader.ReadByte();
                }
            }
        }
        /// <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)
        {
            //IndexId
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                IndexId = reader.ReadBytes(len);
            }

            //TargetIndexName
            TargetIndexName = reader.ReadString();
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //Metadata
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                metadata = reader.ReadBytes(len);
            }

            //VirtualCount
            virtualCount = reader.ReadInt32();
        }
 public void Deserialize(IPrimitiveReader reader, int version)
 {
     if (version == CurrentVersion)
     {
         MessageType   = (MessageType)reader.ReadInt32();
         PayloadLength = reader.ReadInt32();
         int bytesLength = reader.ReadInt32();
         if (bytesLength > -1)
         {
             byte[] bytes = reader.ReadBytes(bytesLength);
             MessageStream = new MemoryStream(bytes);
         }
     }
 }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //MultiItemResult
            if (reader.ReadByte() != 0)
            {
                MultiItemResult = new MultiItemResult();
                MultiItemResult.Deserialize(reader);
            }

            //Metadata
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                Metadata = reader.ReadBytes(len);
            }

            //IndexSize
            IndexSize = reader.ReadInt32();

            //IndexExists
            IndexExists = reader.ReadBoolean();

            //ExceptionInfo
            ExceptionInfo = reader.ReadString();

            //VirtualCount
            if (version >= 2)
            {
                VirtualCount = reader.ReadInt32();
            }

            //IndexCap
            if (version >= 3)
            {
                IndexCap = reader.ReadInt32();
            }

            if (version >= 4)
            {
                //MetadataPropertyCollection
                if (reader.ReadBoolean())
                {
                    MetadataPropertyCollection = new MetadataPropertyCollection();
                    Serializer.Deserialize(reader.BaseStream, MetadataPropertyCollection);
                }
            }
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexId
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                indexId = reader.ReadBytes(len);
            }

            //Offset
            offset = reader.ReadInt32();

            //ItemNum
            itemNum = reader.ReadInt32();

            //TargetIndexName
            targetIndexName = reader.ReadString();

            //Read a byte to account for deprecated CriterionList
            reader.ReadByte();

            //ExcludeData
            excludeData = reader.ReadBoolean();

            //GetMetadata
            getMetadata = reader.ReadBoolean();

            if (version >= 2)
            {
                //Filter
                byte b = reader.ReadByte();
                if (b != 0)
                {
                    FilterType filterType = (FilterType)b;
                    filter = FilterFactory.CreateFilter(reader, filterType);
                }
            }

            if (version >= 3)
            {
                //FullDataIdInfo
                fullDataIdInfo = new FullDataIdInfo();
                Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
            }
        }
Beispiel #28
0
        /// <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())
            {
                //GroupByFieldNameList
                ushort count = reader.ReadUInt16();
                if (count > 0)
                {
                    GroupByFieldNameList = new List <string>(count);
                    for (ushort i = 0; i < count; i++)
                    {
                        GroupByFieldNameList.Add(reader.ReadString());
                    }
                }

                //FieldName
                FieldName = reader.ReadString();

                //FieldValueList
                count = reader.ReadUInt16();
                if (count > 0)
                {
                    FieldValueSet = new HashSet <byte[]>(new ByteArrayEqualityComparer());
                    ushort len;
                    for (ushort i = 0; i < count; i++)
                    {
                        len = reader.ReadUInt16();
                        if (len > 0)
                        {
                            FieldValueSet.Add(reader.ReadBytes(len));
                        }
                    }
                }

                //NonGroupByFieldNameList
                count = reader.ReadUInt16();
                if (count > 0)
                {
                    NonGroupByFieldNameList = new List <string>(count);
                    for (ushort i = 0; i < count; i++)
                    {
                        NonGroupByFieldNameList.Add(reader.ReadString());
                    }
                }
            }
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            using (reader.CreateRegion())
            {
                //InclusiveMaxValue
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    InclusiveMaxValue = reader.ReadBytes(len);
                }

                //InclusiveMinvalue
                len = reader.ReadUInt16();
                if (len > 0)
                {
                    InclusiveMinValue = reader.ReadBytes(len);
                }
            }
        }
        /// <summary>
        /// Deserializes a BitArray from the reader.
        /// </summary>
        /// <param name="bitArray">The bit array</param>
        /// <param name="reader">The primitive writer</param>
        public static void DeserializeBitArray(out BitArray bitArray, IPrimitiveReader reader)
        {
            byte byteCount = reader.ReadByte();

            // Is the BitArray null?
            if (byteCount == byte.MaxValue)
            {
                bitArray = null;
                return;
            }

            // Does the BitArray contain any values?
            if (byteCount == 0)
            {
                bitArray = new BitArray(0, false);
                return;
            }

            // Instantiate the bit array
            bitArray = new BitArray(reader.ReadBytes(byteCount));
        }
        /// <summary>
        /// Deserializes a BitArray from the reader.
        /// </summary>
        /// <param name="bitArray">The bit array</param>
        /// <param name="reader">The primitive writer</param>
        public static void DeserializeBitArray(out BitArray bitArray, IPrimitiveReader reader)
        {
            byte byteCount = reader.ReadByte();

            // Is the BitArray null?
            if (byteCount == byte.MaxValue)
            {
                bitArray = null;
                return;
            }

            // Does the BitArray contain any values?
            if (byteCount == 0)
            {
                bitArray = new BitArray(0, false);
                return;
            }

            // Instantiate the bit array
            bitArray = new BitArray(reader.ReadBytes(byteCount));
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            using (reader.CreateRegion())
            {
                //IndexId
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    indexId = reader.ReadBytes(len);
                }

                //Count
                count = reader.ReadInt32();

                //TargetIndexName
                targetIndexName = reader.ReadString();

                //ExcludeData
                excludeData = reader.ReadBoolean();

                //GetMetadata
                getMetadata = reader.ReadBoolean();

                //Filter
                byte b = reader.ReadByte();
                if (b != 0)
                {
                    FilterType filterType = (FilterType)b;
                    filter = FilterFactory.CreateFilter(reader, filterType);
                }

                if (version >= 2)
                {
                    //FullDataIdInfo
                    fullDataIdInfo = new FullDataIdInfo();
                    Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
                }
            }
        }
Beispiel #33
0
        /// <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);
                }
            }
        }
Beispiel #34
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //Metadata
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                Metadata = reader.ReadBytes(len);
            }

            //VirtualCount
            VirtualCount = reader.ReadInt32();

            if (version >= 2)
            {
                //MetadataPropertyCollection
                if (reader.ReadBoolean())
                {
                    MetadataPropertyCollection = new MetadataPropertyCollection();
                    Serializer.Deserialize(reader.BaseStream, MetadataPropertyCollection);
                }
            }
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexId
            ushort len = reader.ReadUInt16();
            if (len > 0)
            {
                indexId = reader.ReadBytes(len);
            }

            //FirstPageSize
            firstPageSize = reader.ReadInt32();

            //LastPageSize
            lastPageSize = reader.ReadInt32();

            //TargetIndexName
            targetIndexName = reader.ReadString();

            //Read a byte to account for deprecated CriterionList
            reader.ReadByte();

            //ExcludeData
            excludeData = reader.ReadBoolean();

            //GetMetadata
            getMetadata = reader.ReadBoolean();

            if (version >= 2)
            {
                //Filter
                byte b = reader.ReadByte();
                if (b != 0)
                {
                    FilterType filterType = (FilterType)b;
                    filter = FilterFactory.CreateFilter(reader, filterType);
                }
            }

            if(version >= 3)
            {
                //FullDataIdInfo
                fullDataIdInfo = new FullDataIdInfo();
                Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
            }
        }
Beispiel #36
0
        /// <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())
            {
                //FieldName
                FieldName = reader.ReadString();

                //IsTag
                IsTag = reader.ReadBoolean();

                //Operation
                Operation = (Operation)reader.ReadByte();

                //Value
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    Value = reader.ReadBytes(len);
                }

                //DataType
                DataType = (DataType)reader.ReadByte();

                if (version >= 2)
                {
                    //MatchValue
                    len = reader.ReadUInt16();
                    if (len > 0)
                    {
                        ExpectedBitwiseResult = reader.ReadBytes(len);
                    }

                    //ShiftBy
                    ShiftBy = reader.ReadByte();
                }
            }
        }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            using (reader.CreateRegion())
            {
                //IndexId
                ushort len = reader.ReadUInt16();
                if (len > 0)
                {
                    indexId = reader.ReadBytes(len);
                }

                //Count
                count = reader.ReadInt32();

                //TargetIndexName
                targetIndexName = reader.ReadString();

                //ExcludeData
                excludeData = reader.ReadBoolean();

                //GetMetadata
                getMetadata = reader.ReadBoolean();

                //Filter
                byte b = reader.ReadByte();
                if (b != 0)
                {
                    FilterType filterType = (FilterType) b;
                    filter = FilterFactory.CreateFilter(reader, filterType);
                }

                if (version >= 2)
                {
                    //FullDataIdInfo
                    fullDataIdInfo = new FullDataIdInfo();
                    Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
                }
            }
        }
        /// <summary>
        /// Deserializes the internal item.
        /// </summary>
        /// <param name="itemId">The item id.</param>
        /// <param name="inDeserializationContext">The in deserialization context.</param>
        /// <param name="reader">The reader.</param>
        /// <returns>InternalItem</returns>
        private static InternalItem DeserializeInternalItem(byte[] itemId, InDeserializationContext inDeserializationContext, IPrimitiveReader reader)
        {
            byte kvpListCount = reader.ReadByte();

            List<KeyValuePair<int, byte[]>> kvpList = null;
            if (kvpListCount > 0)
            {
                kvpList = new List<KeyValuePair<int, byte[]>>(kvpListCount);
                for (byte j = 0; j < kvpListCount; j++)
                {
                    int tagHashCode = reader.ReadInt32();
                    ushort tagValueLen = reader.ReadUInt16();
                    byte[] tagValue = null;
                    if (tagValueLen > 0)
                    {
                        tagValue = reader.ReadBytes(tagValueLen);
                        if (inDeserializationContext.StringHashCodeDictionary != null &&
                            inDeserializationContext.StringHashCodeDictionary.Count > 0 &&
                            inDeserializationContext.StringHashCodeDictionary.ContainsKey(tagHashCode))
                        {
                            tagValue =
                                inDeserializationContext.StringHashCollection.GetStringByteArray(
                                    inDeserializationContext.TypeId, tagValue);
                        }
                    }
                    kvpList.Add(new KeyValuePair<int, byte[]>(tagHashCode, tagValue));
                }
            }
            return new InternalItem { ItemId = itemId, TagList = kvpList };
        }
        public virtual void Deserialize(IPrimitiveReader reader, int version)
        {
            //TargetIndexName
            targetIndexName = reader.ReadString();

            //IndexIdList
            ushort count = reader.ReadUInt16();
            if (count > 0)
            {
                indexIdList = new List<byte[]>(count);
                ushort len;
                for (ushort i = 0; i < count; i++)
                {
                    len = reader.ReadUInt16();
                    if (len > 0)
                    {
                        indexIdList.Add(reader.ReadBytes(len));
                    }
                }
            }

            //ExcludeData
            excludeData = reader.ReadBoolean();

            //GetIndexHeader
            getIndexHeader = reader.ReadBoolean();

            //PrimaryIdList
            count = reader.ReadUInt16();
            if (count > 0)
            {
                primaryIdList = new List<int>(count);
                for (ushort i = 0; i < count; i++)
                {
                    primaryIdList.Add(reader.ReadInt32());
                }
            }

            //Filter
            byte b = reader.ReadByte();
            if (b != 0)
            {
                FilterType filterType = (FilterType)b;
                filter = FilterFactory.CreateFilter(reader, filterType);
            }

            //IndexIdParamsMapping
            count = reader.ReadUInt16();
            if (count > 0)
            {
                intersectionQueryParamsMapping = new Dictionary<byte[], IntersectionQueryParams>(count, new ByteArrayEqualityComparer());
                byte[] indexId;
                IntersectionQueryParams intersectionQueryParam;
                ushort len;

                for (ushort i = 0; i < count; i++)
                {
                    len = reader.ReadUInt16();
                    indexId = null;
                    if (len > 0)
                    {
                        indexId = reader.ReadBytes(len);

                        intersectionQueryParam = new IntersectionQueryParams();
                        Serializer.Deserialize(reader.BaseStream, intersectionQueryParam);

                        intersectionQueryParamsMapping.Add(indexId, intersectionQueryParam);
                    }
                }
            }

            if (version >= 2)
            {
                //FullDataIdInfo
                fullDataIdInfo = new FullDataIdInfo();
                Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
            }
        }
        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();

                //DeleteFilter
                byte b = reader.ReadByte();
                if (b != 0)
                {
                    FilterType filterType = (FilterType)b;
                    deleteFilter = FilterFactory.CreateFilter(reader, filterType);
                }
            }
        }
        public override void Deserialize(IPrimitiveReader reader, int version)
        {
            //ResultItemList
            int listCount = reader.ReadInt32();
            ResultItemList = new List<ResultItem>(listCount);
            if (listCount > 0)
            {
                ResultItem resultItem;
                for (int i = 0; i < listCount; i++)
                {
                    resultItem = new ResultItem();
                    resultItem.Deserialize(reader);
                    ResultItemList.Add(resultItem);
                }
            }

            //IndexIdIndexHeaderMapping
            ushort count = reader.ReadUInt16();
            if (count > 0)
            {
                IndexIdIndexHeaderMapping = new Dictionary<byte[], IndexHeader>(count, new ByteArrayEqualityComparer());
                byte[] indexId;
                IndexHeader indexHeader;
                ushort len;

                for (ushort i = 0; i < count; i++)
                {
                    len = reader.ReadUInt16();
                    indexId = null;
                    if (len > 0)
                    {
                        indexId = reader.ReadBytes(len);
                    }
                    indexHeader = new IndexHeader();
                    Serializer.Deserialize(reader.BaseStream, indexHeader);

                    IndexIdIndexHeaderMapping.Add(indexId, indexHeader);
                }
            }

            //TotalCount
            TotalCount = reader.ReadInt32();

            //IsTagPrimarySort
            IsTagPrimarySort = reader.ReadBoolean();

            //SortFieldName
            SortFieldName = reader.ReadString();

            //SortOrderList
            count = reader.ReadUInt16();
            SortOrderList = new List<SortOrder>(count);
            SortOrder sortOrder;
            for (int i = 0; i < count; i++)
            {
                sortOrder = new SortOrder();
                sortOrder.Deserialize(reader);
                SortOrderList.Add(sortOrder);
            }

            //ExceptionInfo
            ExceptionInfo = reader.ReadString();

            //AdditionalAvailableItemCount
            AdditionalAvailableItemCount = reader.ReadInt32();
        }
		public void Deserialize(IPrimitiveReader reader, int version)
		{
            //MultiItemResult
            if (reader.ReadByte() != 0)
            {
                multiItemResult = new MultiItemResult();
                multiItemResult.Deserialize(reader);
            }

            //Metadata
            ushort len = reader.ReadUInt16();
            if (len > 0)
            {
                metadata = reader.ReadBytes(len);
            }

            //IndexSize
            indexSize = reader.ReadInt32();

            //IndexExists
            indexExists = reader.ReadBoolean();

            //ExceptionInfo
            exceptionInfo = reader.ReadString();

            //VirtualCount
            if(version >= 2)
            {
                virtualCount = reader.ReadInt32();
            }
        }
        /// <summary>
        /// Skips the deserialization of the internal item.
        /// </summary>
        /// <param name="reader">The reader.</param>
        private static void SkipDeserializeInternalItem(IPrimitiveReader reader)
        {
            var kvpListCount = reader.ReadByte();

            //kvpList          
            if (kvpListCount > 0)
            {
                for (byte j = 0; j < kvpListCount; j++)
                {
                    //tagHashCode 
                    reader.ReadBytes(4);

                    //tagValueLen + value
                    reader.ReadBytes(reader.ReadUInt16());
                }
            }
        }
		public void Deserialize(IPrimitiveReader reader, int version)
		{
			if (version == CurrentVersion)
			{
				MessageType = (MessageType)reader.ReadInt32();
				PayloadLength = reader.ReadInt32();
				int bytesLength = reader.ReadInt32();
				if (bytesLength > -1)
				{
					byte[] bytes = reader.ReadBytes(bytesLength);
					MessageStream = new MemoryStream(bytes);
				}
			}
		}
		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
			int listCount = reader.ReadInt32();
			addList = new List<IndexDataItem>(listCount);
			IndexDataItem indexDataItem;
			for (int i = 0; i < listCount; i++)
			{
				indexDataItem = new IndexDataItem();
				indexDataItem.Deserialize(reader);
				addList.Add(indexDataItem);
			}

			//DeleteList
			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();
            }
		}
Beispiel #46
0
        public virtual void Deserialize(IPrimitiveReader reader)
        {
            //ItemId
            ushort len = reader.ReadUInt16();
            if (len > 0)
            {
                itemId = reader.ReadBytes(len);
            }

            //Tags
            ushort count = reader.ReadUInt16();
            tags = new Dictionary<string, byte[]>(count);
            if (count > 0)
            {
                string tagName;
                byte[] tagValue;
                ushort tagValueLen;

                for (ushort i = 0; i < count; i++)
                {
                    tagName = reader.ReadString();
                    tagValueLen = reader.ReadUInt16();
                    tagValue = null;
                    if (tagValueLen > 0)
                    {
                        tagValue = reader.ReadBytes(tagValueLen);
                    }
                    tags.Add(tagName, tagValue);
                }
            }
        }
		public void Deserialize(IPrimitiveReader reader, int version)
		{
            //IndexId
            ushort len = reader.ReadUInt16();
            if (len > 0)
            {
                indexId = reader.ReadBytes(len);
            }

            //IndexItemList
            ushort count = reader.ReadUInt16();
            if (count > 0)
            {
                IndexItem indexItem;
                indexItemList = new List<IndexItem>(count);
                for (ushort i = 0; i < count; i++)
                {
                    indexItem = new IndexItem();
                    indexItem.Deserialize(reader);
                    indexItemList.Add(indexItem);
                }
            }

            //TargetIndexName
            targetIndexName = reader.ReadString();

            //TagsFromIndexes
            count = reader.ReadUInt16();
            tagsFromIndexes = new List<string>(count);
            if (count > 0)
            {
                for (ushort i = 0; i < count; i++)
                {
                    tagsFromIndexes.Add(reader.ReadString());
                }
            }

            //ExcludeData
            excludeData = reader.ReadBoolean();

            //GetMetadata
            getMetadata = reader.ReadBoolean();

            if(version >= 2)
            {
                //FullDataIdInfo
                fullDataIdInfo = new FullDataIdInfo();
                Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
            }
		}
        /// <summary>
        /// Deserialize the class data from a stream.
        /// </summary>
        /// <param name="reader">The <see cref="IPrimitiveReader"/> that extracts used to extra data from a stream.</param>
        /// <param name="version">The value of <see cref="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)
        {
            //Metadata
            ushort len = reader.ReadUInt16();
            if (len > 0)
            {
                Metadata = reader.ReadBytes(len);
            }

            //VirtualCount
            if (version >= 2)
            {
                virtualCount = reader.ReadInt32();
            }

            //Count
            outDeserializationContext = new OutDeserializationContext { TotalCount = reader.ReadInt32() };

            if (InDeserializationContext.DeserializeHeaderOnly)
            {
                //Note: If InDeserializationContext.DeserializeHeaderOnly property is set then InDeserializationContext.PartialByteArray shall hold all CacheIndexInternal 
                //payload except metadata and header (just virtual count for now). This code path will only be used if just
                //header info like virtual count needs to be updated keeping rest of the index untouched.
                //InDeserializationContext.PartialByteArray shall be used in Serialize code
                outDeserializationContext.UnserializedCacheIndexInternal =
                    new byte[(int)reader.BaseStream.Length - (int)reader.BaseStream.Position + 1];
                reader.BaseStream.Read(outDeserializationContext.UnserializedCacheIndexInternal, 0, outDeserializationContext.UnserializedCacheIndexInternal.Length);
            }
            else
            {
                int actualItemCount = outDeserializationContext.TotalCount;

                //this.InDeserializationContext.MaxItemsPerIndex = 0 indicates need to extract all items
                //this.InDeserializationContext.MaxItemsPerIndex > 0 indicates need to extract only number of items indicated by InDeserializationContext.MaxItemsPerIndex
                if (InDeserializationContext.MaxItemsPerIndex > 0)
                {
                    if (InDeserializationContext.MaxItemsPerIndex < outDeserializationContext.TotalCount)
                    {
                        actualItemCount = InDeserializationContext.MaxItemsPerIndex;
                    }
                }

                #region Populate InternalItemList

                byte[] itemId;
                InternalItem internalItem;
                bool enterConditionPassed = false;

                InternalItemList = new InternalItemList();

                // Note: ---- Termination condition of the loop
                // For full index extraction loop shall terminate because of condition : internalItemList.Count < actualItemCount
                // For partial index extraction loop shall terminate because of following conditions 
                //				a)  i < InDeserializationContext.TotalCount (when no sufficient items are found) OR
                //				b)  internalItemList.Count < actualItemCount (Item extraction cap is reached)																					
                int i = 0;
                while (InternalItemList.Count < actualItemCount && i < outDeserializationContext.TotalCount)
                {
                    i++;

                    #region Deserialize ItemId

                    len = reader.ReadUInt16();
                    if (len > 0)
                    {
                        itemId = reader.ReadBytes(len);
                    }
                    else
                    {
                        throw new Exception("Invalid ItemId - is null or length is zero for IndexId : " +
                                            IndexCacheUtils.GetReadableByteArray(InDeserializationContext.IndexId));
                    }

                    #endregion

                    #region Process IndexCondition

                    if (InDeserializationContext.EnterCondition != null || InDeserializationContext.ExitCondition != null)
                    {
                        #region Have Enter/Exit Condition

                        if (InDeserializationContext.PrimarySortInfo.IsTag == false)
                        {
                            #region Sort by ItemId

                            if (InDeserializationContext.EnterCondition != null && enterConditionPassed == false)
                            {
                                #region enter condition processing

                                if (InDeserializationContext.EnterCondition.Process(itemId))
                                {
                                    enterConditionPassed = true;
                                    internalItem = DeserializeInternalItem(itemId, InDeserializationContext, reader);
                                    ApplyFilterAndAddItem(internalItem);
                                }
                                else
                                {
                                    SkipDeserializeInternalItem(reader);
                                    // no filter processing required
                                }

                                #endregion
                            }
                            else if (InDeserializationContext.ExitCondition != null)
                            {
                                #region exit condition processing

                                if (InDeserializationContext.ExitCondition.Process(itemId))
                                {
                                    // since item passed exit filter, we keep it.
                                    internalItem = DeserializeInternalItem(itemId, InDeserializationContext, reader);
                                    ApplyFilterAndAddItem(internalItem);
                                }
                                else
                                {
                                    // no need to search beyond this point
                                    break;
                                }

                                #endregion
                            }
                            else if (InDeserializationContext.EnterCondition != null && enterConditionPassed && InDeserializationContext.ExitCondition == null)
                            {
                                #region enter condition processing when no exit condition exists

                                internalItem = DeserializeInternalItem(itemId, InDeserializationContext, reader);
                                ApplyFilterAndAddItem(internalItem);

                                #endregion
                            }

                            #endregion
                        }
                        else
                        {
                            byte[] tagValue;

                            #region Deserialize InternalItem and fetch PrimarySortTag value

                            internalItem = DeserializeInternalItem(itemId, InDeserializationContext, reader);
                            if (!internalItem.TryGetTagValue(InDeserializationContext.PrimarySortInfo.FieldName, out tagValue))
                            {
                                throw new Exception("PrimarySortTag Not found:  " + InDeserializationContext.PrimarySortInfo.FieldName);
                            }

                            #endregion

                            #region Sort by Tag

                            if (InDeserializationContext.EnterCondition != null && enterConditionPassed == false)
                            {
                                #region enter condition processing

                                if (InDeserializationContext.EnterCondition.Process(tagValue))
                                {
                                    enterConditionPassed = true;
                                    ApplyFilterAndAddItem(internalItem);
                                }

                                #endregion
                            }
                            else if (InDeserializationContext.ExitCondition != null)
                            {
                                #region exit condition processing

                                if (InDeserializationContext.ExitCondition.Process(tagValue))
                                {
                                    // since item passed exit filter, we keep it.
                                    ApplyFilterAndAddItem(internalItem);
                                }
                                else
                                {
                                    // no need to search beyond this point
                                    break;

                                }

                                #endregion
                            }
                            else if (InDeserializationContext.EnterCondition != null && enterConditionPassed && InDeserializationContext.ExitCondition == null)
                            {
                                #region enter condition processing when no exit condition exists

                                ApplyFilterAndAddItem(internalItem);

                                #endregion
                            }

                            #endregion
                        }

                        #endregion
                    }
                    else
                    {
                        #region No Enter/Exit Condition

                        internalItem = DeserializeInternalItem(itemId, InDeserializationContext, reader);
                        ApplyFilterAndAddItem(internalItem);

                        #endregion
                    }

                    #endregion
                }

                //Set ReadItemCount on OutDeserializationContext
                outDeserializationContext.ReadItemCount = i;

                #endregion
            }
        }