Exemplo n.º 1
0
        internal static Filter CreateFilter(IPrimitiveReader reader, FilterType filterType)
        {
            Filter filter;

            switch (filterType)
            {
                case FilterType.And:                    
                    filter = new AndFilter();                    
                    break;

                case FilterType.Or:
                    filter = new OrFilter();                    
                    break;

                case FilterType.Condition:
                    filter = new Condition();                    
                    break;
                    
                default:
                    throw new Exception("Unknown FilterType " + filterType);
            }

            Serializer.Deserialize(reader.BaseStream, filter);
            return filter;
        }
Exemplo n.º 2
0
		public override void Deserialize(IPrimitiveReader reader)
		{
			base.Deserialize(reader);

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

            //VirtualCount
            virtualCount = reader.ReadInt32();
        }
Exemplo n.º 4
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            using (reader.CreateRegion())
            {
                //RelatedTypeName
                relatedTypeName = reader.ReadString();

                //FullDataIdFieldList
                fullDataIdFieldList = new FullDataIdFieldList();
                Serializer.Deserialize(reader.BaseStream, fullDataIdFieldList);
            }
        }
Exemplo n.º 5
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())
            {
                //FieldName
                FieldName = reader.ReadString();

                //FilterCaps
                FilterCaps = new FilterCaps();
                Serializer.Deserialize(reader.BaseStream, FilterCaps);
            }
        }
 public void Deserialize(IPrimitiveReader reader, int version)
 {
     using (reader.CreateRegion())
     {
         //Filter
         byte b = reader.ReadByte();
         if (b != 0)
         {
             FilterType filterType = (FilterType)b;
             filter = FilterFactory.CreateFilter(reader, filterType);
         }
     }
 }
Exemplo n.º 7
0
        internal static Command CreateCommand(IPrimitiveReader reader, CommandType commandType)
        {
            Command command;

            switch (commandType)
            {
                case CommandType.FilteredIndexDelete:
                    command = new FilteredIndexDeleteCommand();                    
                    break;
                    
                default:
                    throw new Exception("Unknown CommandType " + commandType);
            }

            Serializer.Deserialize(reader.BaseStream, command);
            return command;
        }
Exemplo n.º 8
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);
                }
            }
        }
        /// <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));
        }
Exemplo n.º 10
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);
                }

                if (version >= 2)
                {
                    //FullDataIdInfo
                    fullDataIdInfo = new FullDataIdInfo();
                    Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
                }
            }
        }
Exemplo n.º 11
0
 public abstract void Deserialize(IPrimitiveReader reader, int version);
		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);
            }
		}
        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);
                }
            }
        }
Exemplo n.º 14
0
 public void Deserialize(IPrimitiveReader reader)
 {
     reader.Response = SerializationResponse.Unhandled;
 }
Exemplo n.º 15
0
        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);
            }

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

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

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

            if (version >= 6)
            {
                //DomainSpecificProcessingType
                DomainSpecificProcessingType = (DomainSpecificProcessingType)reader.ReadByte();
            }
        }
Exemplo n.º 16
0
 public void Deserialize(IPrimitiveReader reader, int version)
 {
     using (reader.CreateRegion())
     {
         CommandType commandType = (CommandType)reader.ReadByte();
         command = CommandFactory.CreateCommand(reader, commandType);
     }
 }
Exemplo n.º 17
0
        public static T Deserialize <T>(IPrimitiveReader source, T suggested = default(T))
        {
            var or = new Reader(source);

            return(or.Read <T>(suggested));
        }
        /// <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
            }
        }
Exemplo n.º 19
0
        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);
            }
        }
        /// <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>
		/// Deserializes a color from the reader.
		/// </summary>
		/// <param name="color">The Color struct.</param>
		/// <param name="reader">The primitive reader.</param>
		public static void DeserializeColor(out Color color, IPrimitiveReader reader)
		{
			color = Color.FromArgb(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());
                }
            }
        }
Exemplo n.º 23
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())
            {
                //FullDataIdType
                FullDataIdType = (FullDataIdType)reader.ReadByte();

                //TagName
                TagName = reader.ReadString();

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

                    //Count
                    reader.ReadInt32();

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

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

                    //FullDataIdPartFormat
                    FullDataIdPartFormat = (FullDataIdPartFormat)reader.ReadByte();
                }
            }
        }
        /// <summary>
        /// Deserialize data from a stream
        /// </summary>
        /// <param name="reader"></param>
        public void Deserialize(IPrimitiveReader reader)
        {
            //Note: This is called by legacy code which is using Non-IVersionserializable version of CacheIndexInternal
            // In future it should be replaced with following code

            //reader.Response = SerializationResponse.Unhandled;

            Deserialize(reader, 1);
        }
Exemplo n.º 25
0
        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)
		{
			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);
				}
			}
		}
Exemplo n.º 27
0
		public override void Deserialize(IPrimitiveReader reader, int version)
		{
			Deserialize(reader);
		}
		public void Deserialize(IPrimitiveReader reader)
		{
			Deserialize(reader, CurrentVersion);
		}
Exemplo n.º 29
0
 public override void Deserialize(IPrimitiveReader reader, int version)
 {
     using (reader.CreateRegion())
     {
         FilterType filterType;
         ushort count = reader.ReadUInt16();
         FilterList = new List<Filter>(count);
         Filter childFilter;
         for (ushort i = 0; i < count; i++)
         {
             filterType = (FilterType) reader.ReadByte();
             childFilter = FilterFactory.CreateFilter(reader, filterType);
             FilterList.Add(childFilter);
             totalCount += childFilter.FilterCount;
         }
     }
 }
Exemplo n.º 30
0
 public virtual void Deserialize(IPrimitiveReader reader, int version)
 {
     Deserialize(reader);
 }
 /// <summary>
 /// Reads the serialized header
 /// </summary>
 /// <param name="reader"></param>
 public void Read(IPrimitiveReader reader)
 {
     this.headerPosition = reader.BaseStream.Position;
     this.headerVersion = reader.ReadByte();
     this.headerLength = reader.ReadInt16();
     this.flags = (TypeSerializationHeaderFlags)reader.ReadByte();
     this.dataVersion = reader.ReadByte();
     this.dataMinVersion = reader.ReadByte();
     this.dataLength = reader.ReadInt32();
     this.dataPosition = this.headerPosition + this.headerLength;
     
     if (this.headerVersion > CurrentHeaderVersion)
     {
         throw new ApplicationException("This object was serialized with a newer version of the serialization framework");
     }
     if ((this.flags & ~TypeSerializationHeaderFlags.KnownFlags) != 0)
     {
         throw new ApplicationException("This object was serialized with features that are not supported in this version of the serialization framework");
     }
     
     reader.BaseStream.Seek(this.dataPosition, System.IO.SeekOrigin.Begin);
 }
Exemplo n.º 32
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);
                }
            }
        }
Exemplo n.º 33
0
 public void Deserialize(IPrimitiveReader reader)
 {
     reader.Response = SerializationResponse.Unhandled;
 }
Exemplo n.º 34
0
        /// <summary>
        /// Deserialize an object from a string.
        /// </summary>
        /// <param name="source">The string to read as a serialized object.</param>
        /// <returns>A newly deserialized object.</returns>
        public static object Deserialize(IPrimitiveReader source)
        {
            var or = new Reader(source);

            return(or.Read());
        }