예제 #1
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //IndexDataItem List
            if (Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)Count);
                foreach (IndexDataItem indexDataItem in this)
                {
                    indexDataItem.Serialize(writer);
                }

                //IndexId
                if (indexId == null || indexId.Length == 0)
                {
                    writer.Write((ushort)0);
                }
                else
                {
                    writer.Write((ushort)indexId.Length);
                    writer.Write(indexId);
                }
            }
        }
        /// <summary>
        /// Serializes a BitArray into the writer.
        /// </summary>
        /// <param name="bitArray">The bit array</param>
        /// <param name="writer">The primitive writer</param>
        public static void SerializeBitArray(BitArray bitArray, IPrimitiveWriter writer)
        {
            // Write the byte length
            if (bitArray == null)
            {
                writer.Write(byte.MaxValue); // byte.MaxValue represents null
                return;
            }

            int currentByteLength = (bitArray.Count + 7) / 8;
            if (currentByteLength >= byte.MaxValue)
            {
                throw new ArgumentException("BitArray is too big to be serialized.", "bitArray");
            }
            // Write the byte length
            writer.Write((byte)currentByteLength);
            // Write only if we need to
            if (currentByteLength > 0)
            {
                // Copy the bitarray into a byte array
                byte[] bitArrayBytes = new byte[currentByteLength];
                bitArray.CopyTo(bitArrayBytes, 0);
                // Serialize
                writer.Write(bitArrayBytes);
            }
        }
        /// <summary>
        /// Serializes a BitArray into the writer.
        /// </summary>
        /// <param name="bitArray">The bit array</param>
        /// <param name="writer">The primitive writer</param>
        public static void SerializeBitArray(BitArray bitArray, IPrimitiveWriter writer)
        {
            // Write the byte length
            if (bitArray == null)
            {
                writer.Write(byte.MaxValue); // byte.MaxValue represents null
                return;
            }

            int currentByteLength = (bitArray.Count + 7) / 8;

            if (currentByteLength >= byte.MaxValue)
            {
                throw new ArgumentException("BitArray is too big to be serialized.", "bitArray");
            }
            // Write the byte length
            writer.Write((byte)currentByteLength);
            // Write only if we need to
            if (currentByteLength > 0)
            {
                // Copy the bitarray into a byte array
                byte[] bitArrayBytes = new byte[currentByteLength];
                bitArray.CopyTo(bitArrayBytes, 0);
                // Serialize
                writer.Write(bitArrayBytes);
            }
        }
예제 #4
0
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //Filter
                if (filter == null)
                {
                    writer.Write((byte)0);
                }
                else
                {
                    writer.Write((byte)filter.FilterType);
                    Serializer.Serialize(writer.BaseStream, filter);
                }

                //Count
                writer.Write(Count);

                //IndexCondition
                if (IndexCondition == null)
                {
                    writer.Write(false);
                }
                else
                {
                    writer.Write(true);
                    Serializer.Serialize(writer.BaseStream, IndexCondition);
                }
            }
        }
예제 #5
0
 public override void Serialize(IPrimitiveWriter writer)
 {
     writer.Write(IsEmpty);
     //writer.Write(Id);
     writer.Write(AppId);
     writer.Write(AccessToken);
     writer.Write(ExpireTime);
 }
예제 #6
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //TagName
            writer.Write(tagName);

            //IsTag
            writer.Write(isTag);

            //SortOrder
            sortOrder.Serialize(writer);
        }
예제 #7
0
		public void Serialize(IPrimitiveWriter writer)
		{
			//TagName
			writer.Write(tagName);

			//IsTag
			writer.Write(isTag);

			//SortOrder
			sortOrder.Serialize(writer);
		}
예제 #8
0
 public static void WriteIPEndPoint(this IPrimitiveWriter writer, IPEndPoint value)
 {
     if (value == null)
     {
         writer.Write(false);
     }
     else
     {
         writer.Write(true);
         WriteIPAddress(writer, value.Address);
         writer.WriteVarInt32(value.Port);
     }
 }
예제 #9
0
        public override void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                writer.Write((ushort)FilterList.Count);

                foreach (Filter filter in FilterList)
                {
                    writer.Write((byte)filter.FilterType);
                    Serializer.Serialize(writer.BaseStream, filter);
                }
            }
        }
예제 #10
0
        public static void WriteUri(this IPrimitiveWriter writer, Uri value)
        {
            ArgumentAssert.IsNotNull(writer, "writer");

            if (value == null)
            {
                writer.Write((string)null);
            }
            else
            {
                writer.Write(value.ToString());
            }
        }
예제 #11
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //IndexExists
            writer.Write(IndexExists);

            //DistinctValueCountPairList
            if (DistinctValueCountMapping == null || DistinctValueCountMapping.Count == 0)
            {
                writer.Write(0);
            }
            else
            {
                writer.Write(DistinctValueCountMapping.Count);
                foreach (KeyValuePair <byte[], int> kvp in DistinctValueCountMapping)
                {
                    //Value
                    if (kvp.Key == null || kvp.Key.Length == 0)
                    {
                        writer.Write((ushort)0);
                    }
                    else
                    {
                        writer.Write((ushort)kvp.Key.Length);
                        writer.Write(kvp.Key);

                        //Count
                        writer.Write(kvp.Value);
                    }
                }
            }

            //ExceptionInfo
            writer.Write(ExceptionInfo);
        }
예제 #12
0
        /// <summary>
        /// Serialize the class data to a stream.
        /// </summary>
        /// <param name="writer">The <see cref="T:MySpace.Common.IO.IPrimitiveWriter"/> that writes to the stream.</param>
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //FieldName
                writer.Write(FieldName);

                //FilterCaps
                Serializer.Serialize(writer.BaseStream, FilterCaps);

                //IgnoreNonCappedItems
                writer.Write(IgnoreNonCappedItems);
            }
        }
        public void Serialize(IPrimitiveWriter writer)
        {
            writer.Write(this.pageSize);
            writer.Write(this.pageNum);
            writer.Write(this.minValidDateTime.Ticks);
            writer.Write(IndexIdList.Count);

            if (IndexIdList.Count > 0)
            {
                writer.Write(IndexIdList[0].Length);
                foreach (byte[] indexId in IndexIdList)
                {
                    writer.Write(indexId);
                }
            }

            writer.Write(CacheTypeList.Count);
            if (CacheTypeList.Count > 0)
            {
                foreach (int cacheType in CacheTypeList)
                {
                    writer.Write(cacheType);
                }
            }
        }
예제 #14
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //IndexId
            if (IndexId == null || IndexId.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)IndexId.Length);
                writer.Write(IndexId);
            }

            //FieldName
            writer.Write(FieldName);

            //ItemsToLookUp
            writer.Write(ItemsToLookUp);

            //TargetIndexName
            writer.Write(TargetIndexName);

            //IndexCondition
            if (IndexCondition == null)
            {
                writer.Write(false);
            }
            else
            {
                writer.Write(true);
                Serializer.Serialize(writer.BaseStream, IndexCondition);
            }
        }
        /// <summary>
        /// Serialize the class data to a stream.
        /// </summary>
        /// <param name="writer">The <see cref="T:MySpace.Common.IO.IPrimitiveWriter"/> that writes to the stream.</param>
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //FullDataIdType
                writer.Write((byte)FullDataIdType);

                //TagName
                writer.Write(TagName);

                //Offset
                writer.Write(Offset);

                //Count
                writer.Write(Count);

                //DataType
                writer.Write((byte)DataType);

                //FullDataIdFieldList
                if (FullDataIdFieldList == null)
                {
                    writer.Write(false);
                }
                else
                {
                    writer.Write(true);
                    Serializer.Serialize(writer.BaseStream, FullDataIdFieldList);
                }

                //FullDataIdCollectionType
                writer.Write((byte)FullDataIdPartFormat);
            }
        }
예제 #16
0
		public override void Serialize(IPrimitiveWriter writer)
		{
			base.Serialize(writer);

			//IndexId
			if (indexId == null || indexId.Length == 0)
			{
				writer.Write((ushort)0);
			}
			else
			{
				writer.Write((ushort)indexId.Length);
				writer.Write(indexId);
			}
		}
 public void Serialize(IPrimitiveWriter writer)
 {
     writer.Write((int)MessageType);
     writer.Write(PayloadLength);
     if (MessageStream != null)
     {
         byte[] streamBytes = MessageStream.ToArray();
         writer.Write(streamBytes.Length);
         writer.Write(streamBytes);
     }
     else
     {
         writer.Write(-1);
     }
 }
예제 #18
0
        public override void Serialize(IPrimitiveWriter writer)
        {
            base.Serialize(writer);

            //Data
            if (data == null || data.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)data.Length);
                writer.Write(data);
            }
        }
예제 #19
0
        public override void Serialize(IPrimitiveWriter writer)
        {
            base.Serialize(writer);

            //Data
            if (data == null || data.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)data.Length);
                writer.Write(data);
            }
        }
예제 #20
0
        public override void Serialize(IPrimitiveWriter writer)
        {
            base.Serialize(writer);

            //IndexId
            if (indexId == null || indexId.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)indexId.Length);
                writer.Write(indexId);
            }
        }
예제 #21
0
 private static void SerializeIndexDataItemList(IPrimitiveWriter writer, List <IndexDataItem> indexDataItemList)
 {
     if (indexDataItemList == null || indexDataItemList.Count == 0)
     {
         writer.Write(0);
     }
     else
     {
         writer.Write(indexDataItemList.Count);
         foreach (IndexDataItem indexDataItem in indexDataItemList)
         {
             indexDataItem.Serialize(writer);
         }
     }
 }
예제 #22
0
        /// <summary>
        /// Serialize the class data to a stream.
        /// </summary>
        /// <param name="writer">The <see cref="T:MySpace.Common.IO.IPrimitiveWriter"/> that writes to the stream.</param>
        public void Serialize(IPrimitiveWriter writer)
        {
            //IndexId
            if (IndexId == null || IndexId.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)IndexId.Length);
                writer.Write(IndexId);
            }

            //TargetIndexName
            writer.Write(TargetIndexName);
        }
        /// <summary>
        /// Serialize the class data to a stream.
        /// </summary>
        /// <param name="writer">The <see cref="T:MySpace.Common.IO.IPrimitiveWriter"/> that writes to the stream.</param>
        public void Serialize(IPrimitiveWriter writer)
        {
            //MetadataPropertyCollection
            if (MetadataPropertyCollection == null)
            {
                writer.Write(false);
            }
            else
            {
                writer.Write(true);
                Serializer.Serialize(writer.BaseStream, MetadataPropertyCollection);
            }

            //ExceptionInfo
            writer.Write(ExceptionInfo);
        }
 public void Serialize(IPrimitiveWriter writer)
 {
     using (writer.CreateRegion())
     {
         //Filter
         if (filter == null)
         {
             writer.Write((byte)0);
         }
         else
         {
             writer.Write((byte)filter.FilterType);
             Serializer.Serialize(writer.BaseStream, filter);
         }
     }
 }
예제 #25
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //Metadata
            if (metadata == null || metadata.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)metadata.Length);
                writer.Write(metadata);
            }

            //VirtualCount
            writer.Write(virtualCount);
        }
 public void Serialize(IPrimitiveWriter writer)
 {
     using (writer.CreateRegion())
     {
         //Filter
         if (filter == null)
         {
             writer.Write((byte)0);
         }
         else
         {
             writer.Write((byte)filter.FilterType);
             Serializer.Serialize(writer.BaseStream, filter);
         }
     }
 }
예제 #27
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //Metadata
            if (metadata == null || metadata.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)metadata.Length);
                writer.Write(metadata);
            }

            //VirtualCount
            writer.Write(virtualCount);
        }
예제 #28
0
 internal static long BeginWrite(IPrimitiveWriter writer, int version, int minVersion)
 {
     writer.WriteVarInt32(version);
     writer.WriteVarInt32(minVersion);
     writer.Write(-1);             // reserve
     return(writer.BaseStream.Position);
 }
예제 #29
0
        internal static void EndWrite(IPrimitiveWriter writer, long originalPosition, HeaderFlags flags)
        {
            var currentPosition = writer.BaseStream.Position;

            writer.BaseStream.Seek(originalPosition - 1, SeekOrigin.Begin);
            writer.Write((byte)flags);
            writer.BaseStream.Seek(currentPosition, SeekOrigin.Begin);
        }
예제 #30
0
 public void Serialize(IPrimitiveWriter writer)
 {
     using (writer.CreateRegion())
     {
         writer.Write((byte)command.CommandType);
         Serializer.Serialize(writer.BaseStream, command);
     }
 }
예제 #31
0
        internal static void EndWrite(IPrimitiveWriter writer, long originalPosition)
        {
            long currentPosition = writer.BaseStream.Position;

            writer.BaseStream.Seek(originalPosition - sizeof(int), SeekOrigin.Begin);
            writer.Write((int)(currentPosition - originalPosition));
            writer.BaseStream.Seek(currentPosition, SeekOrigin.Begin);
        }
예제 #32
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //IndexDataItem List
            if (Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)Count);
                foreach (IndexDataItem indexDataItem in this)
                {
                    if (indexDataItem == null)
                    {
                        writer.Write(false);
                    }
                    else
                    {
                        writer.Write(true);
                        Serializer.Serialize(writer.BaseStream, indexDataItem);
                    }
                }

                //IndexId
                if (IndexId == null || IndexId.Length == 0)
                {
                    writer.Write((ushort)0);
                }
                else
                {
                    writer.Write((ushort)IndexId.Length);
                    writer.Write(IndexId);
                }

                //IndexSize
                writer.Write(IndexSize);

                //IndexExists
                writer.Write(IndexExists);

                //IndexCap
                writer.Write(IndexCap);
            }
        }
예제 #33
0
 /// <summary>
 /// Serialize the class data to a stream.
 /// </summary>
 /// <param name="writer">The <see cref="T:MySpace.Common.IO.IPrimitiveWriter"/> that writes to the stream.</param>
 public void Serialize(IPrimitiveWriter writer)
 {
     using (writer.CreateRegion())
     {
         //OrderedBag
         if (ItemBag == null || ItemBag.Count == 0)
         {
             writer.Write((ushort)0);
         }
         else
         {
             writer.Write((ushort)ItemBag.Count);
             foreach (var resultItem in ItemBag)
             {
                 resultItem.Serialize(writer);
             }
         }
     }
 }
예제 #34
0
 /// <summary>
 /// Serialize the class data to a stream.
 /// </summary>
 /// <param name="writer">The <see cref="T:MySpace.Common.IO.IPrimitiveWriter"/> that writes to the stream.</param>
 public void Serialize(IPrimitiveWriter writer)
 {
     using (writer.CreateRegion())
     {
         if (Count == 0)
         {
             writer.Write((ushort)0);
         }
         else
         {
             writer.Write((ushort)Count);
             foreach (FilterCap filterCap in this)
             {
                 //FilterCap
                 Serializer.Serialize(writer.BaseStream, filterCap);
             }
         }
     }
 }
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //RelatedTypeName
                writer.Write(relatedTypeName);

                //FullDataIdFieldList
                Serializer.Serialize(writer.BaseStream, fullDataIdFieldList);
            }
        }
예제 #36
0
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //RelatedTypeName
                writer.Write(relatedTypeName);

                //FullDataIdFieldList
                Serializer.Serialize(writer.BaseStream, fullDataIdFieldList);
            }
        }
예제 #37
0
        /// <summary>
        /// Serialize the class data to a stream.
        /// </summary>
        /// <param name="writer">The <see cref="T:MySpace.Common.IO.IPrimitiveWriter"/> that writes to the stream.</param>
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //FieldName
                writer.Write(FieldName);

                //FilterCaps
                Serializer.Serialize(writer.BaseStream, FilterCaps);
            }
        }
예제 #38
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //Metadata
            if (Metadata == null || Metadata.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)Metadata.Length);
                writer.Write(Metadata);
            }

            //VirtualCount
            writer.Write(VirtualCount);

            //MetadataPropertyCollection
            if (MetadataPropertyCollection == null)
            {
                writer.Write(false);
            }
            else
            {
                writer.Write(true);
                Serializer.Serialize(writer.BaseStream, MetadataPropertyCollection);
            }
        }
예제 #39
0
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //InclusiveMaxValue
                if (InclusiveMaxValue == null || InclusiveMaxValue.Length == 0)
                {
                    writer.Write((ushort)0);
                }
                else
                {
                    writer.Write((ushort)InclusiveMaxValue.Length);
                    writer.Write(InclusiveMaxValue);
                }

                //InclusiveMinvalue
                if (InclusiveMinValue == null || InclusiveMinValue.Length == 0)
                {
                    writer.Write((ushort)0);
                }
                else
                {
                    writer.Write((ushort)InclusiveMinValue.Length);
                    writer.Write(InclusiveMinValue);
                }
            }
        }
예제 #40
0
        public virtual void Serialize(IPrimitiveWriter writer)
        {
            //ItemId
            if (itemId == null || itemId.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)itemId.Length);
                writer.Write(itemId);
            }

            //Tags
            if (tags == null || tags.Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)tags.Count);
                foreach (KeyValuePair<string /*TagName*/, byte[] /*TagValue*/> kvp in tags)
                {
                    writer.Write(kvp.Key);
                    if (kvp.Value == null || kvp.Value.Length == 0)
                    {
                        writer.Write((ushort)0);
                    }
                    else
                    {
                        writer.Write((ushort)kvp.Value.Length);
                        writer.Write(kvp.Value);
                    }
                }
            }

        }
예제 #41
0
        /// <summary>
        /// Serialize the class data to a stream.
        /// </summary>
        /// <param name="writer">The <see cref="T:MySpace.Common.IO.IPrimitiveWriter"/> that writes to the stream.</param>
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //FullDataIdType
                writer.Write((byte)FullDataIdType);

                //TagName
                writer.Write(TagName);

                //Offset
                writer.Write(Offset);

                //Count
                writer.Write(Count);

                //DataType
                writer.Write((byte)DataType);

                //FullDataIdFieldList
                if (FullDataIdFieldList == null)
                {
                    writer.Write(false);
                }
                else
                {
                    writer.Write(true);
                    Serializer.Serialize(writer.BaseStream, FullDataIdFieldList);
                }

                //FullDataIdCollectionType
                writer.Write((byte)FullDataIdPartFormat);
            }
        }
 /// <summary>
 /// Writes or updates the serialized header
 /// </summary>
 /// <param name="writer"></param>
 public void Write(IPrimitiveWriter writer)
 {
     long    oldPosition = writer.BaseStream.Position;
     bool    firstWrite = this.headerPosition < 0;
     
     //  Assumes the first time this header is written that
     //  we're adding it to the stream with some data missing
     //  Subsequent writes are intended to update the header
     //  with new info such as the actual data length
     if (firstWrite)
     {
         this.headerPosition = oldPosition;
     }
     else
     {
         writer.BaseStream.Seek(this.headerPosition, System.IO.SeekOrigin.Begin);
     }
     
     writer.Write(this.headerVersion);
     writer.Write(this.headerLength);
     writer.Write((byte)this.flags);
     writer.Write(this.dataVersion);
     writer.Write(this.dataMinVersion);
     writer.Write(this.dataLength);
     
     if (firstWrite)
     {
         this.dataPosition = writer.BaseStream.Position;
         this.headerLength = (short)(this.dataPosition - this.headerPosition);
     }
     else
     {
         writer.BaseStream.Seek(oldPosition, System.IO.SeekOrigin.Begin);
     }
 }
예제 #43
0
        public void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //IndexId
                if (indexId == null || indexId.Length == 0)
                {
                    writer.Write((ushort) 0);
                }
                else
                {
                    writer.Write((ushort) indexId.Length);
                    writer.Write(indexId);
                }

                //Count
                writer.Write(count);

                //TargetIndexName
                writer.Write(targetIndexName);

                //ExcludeData
                writer.Write(excludeData);

                //GetMetadata
                writer.Write(getMetadata);

                //Filter
                if (filter == null)
                {
                    writer.Write((byte) 0);
                }
                else
                {
                    writer.Write((byte) filter.FilterType);
                    Serializer.Serialize(writer.BaseStream, filter);
                }

                //FullDataIdInfo
                Serializer.Serialize(writer.BaseStream, fullDataIdInfo);
            }
        }
		public void Serialize(IPrimitiveWriter writer)
		{
            //MultiItemResult
            if(multiItemResult == null || multiItemResult.Count == 0)
            {
                writer.Write((byte)0);
            }
            else
            {
                writer.Write((byte)1);
                multiItemResult.Serialize(writer);
            }

			//Metadata
			if (metadata == null || metadata.Length == 0)
			{
				writer.Write((ushort)0);
			}
			else
			{
				writer.Write((ushort)metadata.Length);
				writer.Write(metadata);
			}

			//IndexSize
			writer.Write(indexSize);

			//IndexExists
			writer.Write(indexExists);

			//ExceptionInfo
			writer.Write(exceptionInfo);

            //VirtualCount
            writer.Write(virtualCount);
		}
예제 #45
0
        public override void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                writer.Write((ushort) FilterList.Count);

                foreach (Filter filter in FilterList)
                {
                    writer.Write((byte) filter.FilterType);
                    Serializer.Serialize(writer.BaseStream, filter);
                }
            }
        }
        public virtual void Serialize(IPrimitiveWriter writer)
        {
            //TargetIndexName
            writer.Write(targetIndexName);

            //IndexIdList
            if (indexIdList == null || indexIdList.Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)indexIdList.Count);
                foreach (byte[] indexId in indexIdList)
                {
                    if (indexId == null || indexId.Length == 0)
                    {
                        writer.Write((ushort)0);
                    }
                    else
                    {
                        writer.Write((ushort)indexId.Length);
                        writer.Write(indexId);
                    }
                }
            }

            //ExcludeData
            writer.Write(excludeData);

            //GetIndexHeader
            writer.Write(getIndexHeader);

            //PrimaryIdList
            if (primaryIdList == null || primaryIdList.Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)primaryIdList.Count);
                foreach (int primaryId in primaryIdList)
                {
                    writer.Write(primaryId);
                }
            }

            //Filter
            if (filter == null)
            {
                writer.Write((byte)0);
            }
            else
            {
                writer.Write((byte)filter.FilterType);
                Serializer.Serialize(writer.BaseStream, filter);
            }

            //IndexIdParamsMapping
            if (intersectionQueryParamsMapping == null || intersectionQueryParamsMapping.Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)intersectionQueryParamsMapping.Count);
                foreach (KeyValuePair<byte[] /*IndexId*/, IntersectionQueryParams /*IntersectionQueryParams*/> kvp in intersectionQueryParamsMapping)
                {
                    //IndexId
                    if (kvp.Key == null || kvp.Key.Length == 0)
                    {
                        writer.Write((ushort)0);

                        //No need to serialize IntersectionQueryParams
                    }
                    else
                    {
                        writer.Write((ushort)kvp.Key.Length);
                        writer.Write(kvp.Key);

                        //IntersectionQueryParams
                        Serializer.Serialize(writer, kvp.Value);
                    }
                }
            }

            //FullDataIdInfo
            Serializer.Serialize(writer.BaseStream, fullDataIdInfo);
        }
예제 #47
0
        /// <summary>
        /// Serializes the specified writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public override void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //FieldName
                writer.Write(FieldName);

                //IsTag
                writer.Write(IsTag);

                //Operation
                writer.Write((byte)Operation);

                //Value
                if (Value == null || Value.Length == 0)
                {
                    writer.Write((ushort)0);
                }
                else
                {
                    writer.Write((ushort)Value.Length);
                    writer.Write(Value);
                }

                //DataType
                writer.Write((byte)DataType);

                //MatchValue
                if (ExpectedBitwiseResult == null || ExpectedBitwiseResult.Length == 0)
                {
                    writer.Write((ushort)0);
                }
                else
                {
                    writer.Write((ushort)ExpectedBitwiseResult.Length);
                    writer.Write(ExpectedBitwiseResult);
                }

                //ShiftBy
                writer.Write(ShiftBy);
            }
        }
        /// <summary>
        /// Serialize the class data to a stream.
        /// </summary>
        /// <param name="writer">The <see cref="IPrimitiveWriter"/> that writes to the stream.</param>
        public void Serialize(IPrimitiveWriter writer)
        {
            //Metadata
            if (Metadata == null || Metadata.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)Metadata.Length);
                writer.Write(Metadata);
            }

            if (!LegacySerializationUtil.Instance.IsSupported(InDeserializationContext.TypeId))
            {
                //VirtualCount
                writer.Write(virtualCount);
            }

            // Note: If InDeserializationContext.DeserializeHeaderOnly property is set then InDeserializationContext.UnserializedCacheIndexInternal shall hold all CacheIndexInternal 
            // payload except metadata and virtual count. This code path will only be used if just header info like 
            // virtual count needs to be updated keeping rest of the index untouched
            if (InDeserializationContext.DeserializeHeaderOnly &&
                outDeserializationContext.UnserializedCacheIndexInternal != null &&
                outDeserializationContext.UnserializedCacheIndexInternal.Length != 0)
            {
                //Count
                writer.Write(outDeserializationContext.TotalCount);

                // UnserializedCacheIndexInternal
                writer.BaseStream.Write(outDeserializationContext.UnserializedCacheIndexInternal, 0, outDeserializationContext.UnserializedCacheIndexInternal.Length);
            }
            else
            {
                //Count
                if (InternalItemList == null || InternalItemList.Count == 0)
                {
                    writer.Write(0);
                }
                else
                {
                    writer.Write(InternalItemList.Count);

                    for (int i = 0; i < InternalItemList.Count; i++)
                    {
                        //Id
                        if (InternalItemList[i].ItemId == null || InternalItemList[i].ItemId.Length == 0)
                        {
                            throw new Exception("Invalid ItemId - is null or length is zero for IndexId : " +
                                                IndexCacheUtils.GetReadableByteArray(InDeserializationContext.IndexId));
                        }
                        writer.Write((ushort)InternalItemList[i].ItemId.Length);
                        writer.Write(InternalItemList[i].ItemId);

                        //(byte)KvpListCount
                        if (InternalItemList[i].TagList == null || InternalItemList[i].TagList.Count == 0)
                        {
                            writer.Write((byte)0);
                        }
                        else
                        {
                            writer.Write((byte)InternalItemList[i].TagList.Count);

                            //KvpList
                            byte[] stringHashValue;
                            foreach (KeyValuePair<int /*TagHashCode*/, byte[] /*TagValue*/> kvp in InternalItemList[i].TagList)
                            {
                                writer.Write(kvp.Key);
                                if (kvp.Value == null || kvp.Value.Length == 0)
                                {
                                    writer.Write((ushort)0);
                                }
                                else
                                {
                                    if (InDeserializationContext.StringHashCodeDictionary != null &&
                                        InDeserializationContext.StringHashCodeDictionary.Count > 0 &&
                                        InDeserializationContext.StringHashCodeDictionary.ContainsKey(kvp.Key))
                                    {
                                        InDeserializationContext.StringHashCollection.AddStringArray(InDeserializationContext.TypeId, kvp.Value);
                                        stringHashValue = StringHashCollection.GetHashCodeByteArray(kvp.Value);
                                        writer.Write((ushort)stringHashValue.Length);
                                        writer.Write(stringHashValue);
                                    }
                                    else
                                    {
                                        writer.Write((ushort)kvp.Value.Length);
                                        writer.Write(kvp.Value);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
		public void Serialize(IPrimitiveWriter writer)
		{
			writer.Write((int)MessageType);
			writer.Write(PayloadLength);
			if (MessageStream != null)
			{
				byte[] streamBytes = MessageStream.ToArray();
				writer.Write(streamBytes.Length);
				writer.Write(streamBytes);
			}
			else
			{
				writer.Write(-1);
			}
		}
예제 #50
0
        public override void Serialize(IPrimitiveWriter writer)
        {
            //ResultItemList
            if (ResultItemList == null || ResultItemList.Count == 0)
            {
                writer.Write(0);
            }
            else
            {
                writer.Write(ResultItemList.Count);
                foreach (ResultItem resultItem in ResultItemList)
                {
                    resultItem.Serialize(writer);
                }
            }

            //IndexIdIndexHeaderMapping
            if (IndexIdIndexHeaderMapping == null || IndexIdIndexHeaderMapping.Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)IndexIdIndexHeaderMapping.Count);
                foreach (KeyValuePair<byte[] /*IndexId*/, IndexHeader /*IndexHeader*/> kvp in IndexIdIndexHeaderMapping)
                {
                    //IndexId
                    if (kvp.Key == null || kvp.Key.Length == 0)
                    {
                        writer.Write((ushort)0);
                    }
                    else
                    {
                        writer.Write((ushort)kvp.Key.Length);
                        writer.Write(kvp.Key);
                    }

                    //IndexHeader
                    Serializer.Serialize(writer, kvp.Value);
                }
            }

            //TotalCount
            writer.Write(TotalCount);

            //IsTagPrimarySort
            writer.Write(IsTagPrimarySort);

            //SortFieldName
            // Note : this field will only be needed if PrimarySort field is tag
            if (IsTagPrimarySort)
            {
                writer.Write(SortFieldName);
            }
            else
            {
                writer.Write("");
            }

            //SortOrderList
            if (SortOrderList == null || SortOrderList.Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)SortOrderList.Count);
                foreach (SortOrder sortOrder in SortOrderList)
                {
                    sortOrder.Serialize(writer);
                }
            }

            //ExceptionInfo
            writer.Write(ExceptionInfo);

            //AdditionalAvailableItemCount
            writer.Write(AdditionalAvailableItemCount);
        }
		/// <summary>
		/// Serializes a color into the writer.
		/// </summary>
		/// <param name="color">The Color struct.</param>
		/// <param name="writer">The primitive writer.</param>
		public static void SerializeColor(Color color, IPrimitiveWriter writer)
		{
			writer.Write(color.ToArgb());
		}
예제 #52
0
		public void Serialize(IPrimitiveWriter writer)
		{
			//IndexId
			if (indexId == null || indexId.Length == 0)
			{
				writer.Write((ushort)0);
			}
			else
			{
				writer.Write((ushort)indexId.Length);
				writer.Write(indexId);
			}

			//TargetIndexName
			writer.Write(targetIndexName);

			//IndexTagMapping
			if (indexTagMapping == null || indexTagMapping.Count == 0)
			{
				writer.Write((ushort)0);
			}
			else
			{
				writer.Write((ushort)indexTagMapping.Count);
				foreach (KeyValuePair<string /*IndexName*/, List<string> /*TagNameList*/> kvp in indexTagMapping)
				{
					writer.Write(kvp.Key);
					if (kvp.Value == null || kvp.Value.Count == 0)
					{
						writer.Write((ushort)0);
					}
					else
					{
						writer.Write((ushort)kvp.Value.Count);
						foreach (string str in kvp.Value)
						{
							writer.Write(str);
						}
					}
				}
			}

			//AddList
			if (addList == null || addList.Count == 0)
			{
				writer.Write(0);
			}
			else
			{
				writer.Write(addList.Count);
				foreach (IndexDataItem indexDataItem in addList)
				{
					indexDataItem.Serialize(writer);
				}
			}

			//DeleteList
			if (deleteList == null || deleteList.Count == 0)
			{
				writer.Write(0);
			}
			else
			{
				writer.Write(deleteList.Count);
				foreach (IndexItem indexItem in deleteList)
				{
					indexItem.Serialize(writer);
				}
			}

			//Metadata
			if (metadata == null || metadata.Length == 0)
			{
				writer.Write((ushort)0);
			}
			else
			{
				writer.Write((ushort)metadata.Length);
				writer.Write(metadata);
			}

			//UpdateMetadata
			writer.Write(updateMetadata);

			//ReplaceFullIndex
			writer.Write(replaceFullIndex);

            //PreserveData
            writer.Write(preserveData);

            //IndexVirtualCountMapping
            if (indexVirtualCountMapping == null || indexVirtualCountMapping.Count == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)indexVirtualCountMapping.Count);
                foreach (KeyValuePair<string /*IndexName*/, int /*VirtualCount*/> kvp in indexVirtualCountMapping)
                {
                    writer.Write(kvp.Key);
                    writer.Write(kvp.Value);
                }
            }

            //PrimaryId
            writer.Write(primaryId);
		}
예제 #53
0
        public void Serialize(IPrimitiveWriter writer)
        {
            //IndexId
            if (indexId == null || indexId.Length == 0)
            {
                writer.Write((ushort)0);
            }
            else
            {
                writer.Write((ushort)indexId.Length);
                writer.Write(indexId);
            }

            //FirstPageSize
            writer.Write(firstPageSize);

            //LastPageSize
            writer.Write(lastPageSize);

            //TargetIndexName
            writer.Write(targetIndexName);

            //Write a byte to account for deprecated CriterionList
            writer.Write((byte)0);

            //ExcludeData
            writer.Write(excludeData);

            //GetMetadata
            writer.Write(getMetadata);

            //Filter
            if (filter == null)
            {
                writer.Write((byte)0);
            }
            else
            {
                writer.Write((byte)filter.FilterType);
                Serializer.Serialize(writer.BaseStream, filter);
            }

            //FullDataIdInfo
            Serializer.Serialize(writer.BaseStream, fullDataIdInfo);
        }
		public void Serialize(IPrimitiveWriter writer)
		{
			//IndexId
			if (indexId == null || indexId.Length == 0)
			{
				writer.Write((ushort)0);
			}
			else
			{
				writer.Write((ushort)indexId.Length);
				writer.Write(indexId);
			}

			//IndexItemList
            if(indexItemList == null || indexItemList.Count == 0)
            {
				writer.Write((ushort)0);
			}
			else
			{
				writer.Write((ushort)indexItemList.Count);
                foreach(IndexItem indexItem in indexItemList)
                {
                    indexItem.Serialize(writer);
                }
			}

			//TargetIndexName
			writer.Write(targetIndexName);

			//TagsFromIndexes
			if (tagsFromIndexes == null || tagsFromIndexes.Count == 0)
			{
				writer.Write((ushort)0);
			}
			else
			{
				writer.Write((ushort)tagsFromIndexes.Count);
				foreach (string str in tagsFromIndexes)
				{
					writer.Write(str);
				}
			}

			//ExcludeData
			writer.Write(excludeData);

			//GetMetadata
			writer.Write(getMetadata);

            //FullDataIdInfo
		    Serializer.Serialize(writer.BaseStream, fullDataIdInfo);
		}
예제 #55
0
 public void Serialize(IPrimitiveWriter writer)
 {
     using (writer.CreateRegion())
     {
         writer.Write((byte)command.CommandType);
         Serializer.Serialize(writer.BaseStream, command);
     }
 }
        public override void Serialize(IPrimitiveWriter writer)
        {
            using (writer.CreateRegion())
            {
                //IndexId
                if (indexId == null || indexId.Length == 0)
                {
                    writer.Write((ushort)0);
                }
                else
                {
                    writer.Write((ushort)indexId.Length);
                    writer.Write(indexId);
                }

                //TargetIndexName
                writer.Write(targetIndexName);

                //DeleteFilter
                if (deleteFilter == null)
                {
                    writer.Write((byte)0);
                }
                else
                {
                    writer.Write((byte)deleteFilter.FilterType);
                    Serializer.Serialize(writer.BaseStream, deleteFilter);
                }
            }
        }