/// <summary>
        /// Converts to tag dictionary.
        /// </summary>
        /// <param name="tagList">The tag list.</param>
        /// <param name="inDeserializationContext">The InDeserializationContext.</param>
        /// <returns></returns>
        internal static Dictionary<string /*TagName*/, byte[] /* TagValue*/> ConvertToTagDictionary(
            List<KeyValuePair<int /*TagHashCode*/, byte[] /*TagName*/>> tagList,
            InDeserializationContext inDeserializationContext)
        {
            Dictionary<string /*TagName*/, byte[] /*TagValue*/> tagsDictionary = null;

            if (tagList != null && tagList.Count > 0)
            {
                tagsDictionary = new Dictionary<string, byte[]>(tagList.Count);
                foreach (KeyValuePair<int /*TagName*/, byte[] /*TagValue*/> kvp in tagList)
                {
                    string tagName = inDeserializationContext.TagHashCollection.GetTagName(inDeserializationContext.TypeId, kvp.Key);
                    if (!tagsDictionary.ContainsKey(tagName))
                    {
                        tagsDictionary.Add(tagName, kvp.Value);
                    }
                }
            }
            return tagsDictionary;
        }
        /// <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 };
        }
 /// <summary>
 /// Converts an InternalItem to an IndexItem.
 /// </summary>
 /// <param name="internalItem">The internal item.</param>
 /// <param name="inDeserializationContext">The in deserialization context.</param>
 /// <returns></returns>
 internal static IndexItem ConvertToIndexItem(InternalItem internalItem, InDeserializationContext inDeserializationContext)
 {
     return new IndexItem(internalItem.ItemId, ConvertToTagDictionary(internalItem.TagList, inDeserializationContext));
 }