Beispiel #1
0
 public void PackToMessage(Packer pk, PackingOptions options)
 {
     pk.PackArrayHeader(5);
     pk.PackString(uri);
     pk.PackString(title);
     pk.Pack(width);
     pk.Pack(height);
     pk.Pack(size);
 }
Beispiel #2
0
		public void PackToMessage( Packer pk, PackingOptions options )
		{
			pk.PackArrayHeader( 5 );
			pk.PackString( uri );
			pk.PackString( title );
			pk.Pack( width );
			pk.Pack( height );
			pk.Pack( size );
		}
Beispiel #3
0
        public void PackToMessage(Packer packer, PackingOptions options)
        {
            packer.PackMapHeader(2);
            packer.Pack("__type");
            packer.Pack("MetaField");

            packer.Pack("fieldId");
            packer.Pack(FieldId);
        }
 public void PackToMessage(Packer packer, PackingOptions options)
 {
     packer.PackMapHeader(3);
     packer.PackString("graphName");
     packer.Pack(this.graphName);
     packer.PackString("graphObjName");
     packer.Pack(this.graphObjName);
     packer.PackString("killSession");
     packer.Pack(this.killSession);
 }
		public void PackToMessage( Packer packer, PackingOptions options )
		{
			// Pack fields are here:
			// First, record total fields size.
			packer.PackArrayHeader( 2 );
			packer.Pack( this.Id );
			packer.PackString( this.Name );

			// ...Instead, you can pack as map as follows:
			// packer.PackMapHeader( 2 );
			// packer.Pack( "Id" );
			// packer.Pack( this.Id );
			// packer.Pack( "Name" );
			// packer.Pack( this.Name );
		}
        public void PackToMessage(Packer packer, PackingOptions options)
        {
            packer.PackMapHeader(this.inSession ? 4 : 6)
                  .PackString("channel")
                  .Pack(Channel.MsgPack)
                  .PackString("inSession")
                  .Pack(this.inSession)
                  .PackString("isolate")
                  .Pack(this.isolate)
                  .PackString("transaction")
                  .Pack(this.transaction);

            if (!this.inSession)
            {
                packer.PackString("graphName")
                      .PackString(this.graphName)
                      .PackString("graphObjName")
                      .PackString(this.graphObjName);
            }
        }
 /// <summary>
 /// Use msgpack to compress the data
 /// </summary>
 /// <param name="packer">
 /// The msgpack packer
 /// </param>
 /// <param name="options">
 /// msgpack packing options
 /// </param>
 public void PackToMessage(Packer packer, PackingOptions options)
 {
     packer.PackArrayHeader(this.Values.Count);
     foreach (object obj in this.Values)
     {
         if (obj.GetType() == typeof(string))
         {
             string temp = (string)obj;
             packer.PackString(temp, Encoding.GetEncoding("UTF-8"));
         }
         else if (obj.GetType() == typeof(Single))
         {
             float temp = (Single)obj;
             packer.Pack<float>(temp);
         }
         else if (obj.GetType() == typeof(int))
         {
             int temp = (Int32)obj;
             packer.Pack(temp);
         }
     }
 }
 /// <summary>
 /// Use msgpack to compress the data
 /// </summary>
 /// <param name="packer">
 /// The msgpack packer
 /// </param>
 /// <param name="options">
 /// msgpack packing options
 /// </param>
 public void PackToMessage(Packer packer, PackingOptions options)
 {
     packer.PackArrayHeader(this.Values.Count);
     foreach (MessagePackObject obj in this.Values)
     {
         if (obj.IsTypeOf(typeof(string)) == true)
         {
             string temp = obj.AsStringUtf8();
             packer.PackString(temp);
         }
         else if (obj.IsTypeOf(typeof(Single)) == true)
         {
             float temp = obj.AsSingle();
             packer.Pack<float>(temp);
         }
         else if (obj.IsTypeOf(typeof(int)) == true)
         {
             int temp = obj.AsInt32();
             packer.Pack(temp);
         }
     }
 }
        /// <summary>
        /// </summary>
        /// <param name="packer">
        /// </param>
        /// <param name="options">
        /// </param>
        public void PackToMessage(Packer packer, PackingOptions options)
        {
            // Serialize type name of the data object
            packer.Pack(this.typeName);

            // Serialize the data object itself as a byte array
            packer.Pack(this.dataObject.GetData());
        }
Beispiel #10
0
 public void PackToMessage(Packer packer, PackingOptions options)
 {
     // 0xC3
     packer.Pack(true);
 }
Beispiel #11
0
 private void StreamWrite <TItem>(IEnumerable <TItem> value, Action <IEnumerable <TItem>, PackingOptions> writeBody, PackingOptions options)
 {
     if (this.CanSeek)
     {
         this.SeekTo(4L);
         long position = this.Position;
         writeBody(value, options);
         long offset = this.Position - position;
         this.SeekTo(-offset);
         this.SeekTo(-4L);
         this.WriteByte((byte)((offset >> 0x18) & 0xffL));
         this.WriteByte((byte)((offset >> 0x10) & 0xffL));
         this.WriteByte((byte)((offset >> 8) & 0xffL));
         this.WriteByte((byte)(offset & 0xffL));
         this.SeekTo(offset);
     }
     else
     {
         ICollection <TItem> is2 = value as ICollection <TItem>;
         if (is2 == null)
         {
             is2 = value.ToArray <TItem>();
         }
         int count = is2.Count;
         this.WriteByte((byte)((count >> 0x18) & 0xff));
         this.WriteByte((byte)((count >> 0x10) & 0xff));
         this.WriteByte((byte)((count >> 8) & 0xff));
         this.WriteByte((byte)(count & 0xff));
         writeBody(is2, options);
     }
 }
 public void PackToMessage(Packer packer, PackingOptions options)
 {
     packer.Pack(count);
     packer.PackString(data);
 }
			public void PackToMessage( Packer packer, PackingOptions options )
			{
				// 0xC3
				packer.Pack( true );
			}
Beispiel #14
0
        /// <summary>
        ///     Packs the candidate to a MessagePack objects
        ///     This method should not be called directly, use serialize instead.
        /// </summary>
        /// <param name="packer">The packer</param>
        /// <param name="options">The packer options</param>
        public void PackToMessage(Packer packer, PackingOptions options)
        {
            // pack the header for the amount of items in the map
            packer.PackMapHeader(MapCount);

            packer.Pack("DCS");
            packer.Pack(Dcs);

            packer.Pack("DAC");
            packer.Pack(Dac);

            packer.Pack("DAD");
            packer.Pack(Dad);

            packer.Pack("DBD");
            packer.Pack(Dbd.ToString(DateFormat, CultureInfo.InvariantCulture));

            packer.Pack("DBB");
            packer.Pack(Dbb.ToString(DateFormat, CultureInfo.InvariantCulture));

            packer.Pack("DBC");
            packer.Pack((int) Dbc);

            packer.Pack("DAY");
            packer.Pack(Day.AnsiFormat());

            packer.Pack("DAU");
            packer.Pack(Dau.AnsiFormat);

            packer.Pack("DAG");
            packer.Pack(Dag);

            packer.Pack("DAI");
            packer.Pack(Dai);

            packer.Pack("DAJ");
            packer.Pack(Daj);

            packer.Pack("DAK");
            packer.Pack(Dak.AnsiFormat);

            packer.Pack("DCG");
            packer.Pack(Dcg);

            // pack image
            packer.Pack("ZAA");
            var imageConverter = new ImageConverter();
            packer.Pack((byte[]) imageConverter.ConvertTo(Image, typeof (byte[])));

            // pack fingerprint
            packer.Pack("ZAB");

            if (Fingerprint.Image != null) {
                var afis = new AfisEngine();
                var p = new Person(Fingerprint);
                afis.Extract(p);
            }
            if (Fingerprint.AsIsoTemplate != null) packer.Pack(Fingerprint.AsIsoTemplate);
        }
        public void PackToMessage(Packer packer, PackingOptions options)
        {
            packer.Pack((byte)RequestType);

            PackToMessageCore(packer);
        }
Beispiel #16
0
        private void StreamWrite <TItem>(IEnumerable <TItem> value, Action <IEnumerable <TItem>, PackingOptions> writeBody, PackingOptions options)
        {
            if (this.CanSeek)
            {
                // Reserve length
                this.SeekTo(4L);
                var headerPosition = this.Position;
                // Write body
                writeBody(value, options);
                var bodyLength = this.Position - headerPosition;
                // Back to reserved length
                this.SeekTo(-bodyLength);
                this.SeekTo(-4L);
                unchecked
                {
                    this.WriteByte(( byte )((bodyLength >> 24) & 0xff));
                    this.WriteByte(( byte )((bodyLength >> 16) & 0xff));
                    this.WriteByte(( byte )((bodyLength >> 8) & 0xff));
                    this.WriteByte(( byte )(bodyLength & 0xff));
                }
                // Forward to body tail
                this.SeekTo(bodyLength);
            }
            else
            {
                // Copying is better than forcing stream is seekable...
                ICollection <TItem> asCollection = value as ICollection <TItem>;
                if (asCollection == null)
                {
                    asCollection = value.ToArray();
                }

                var bodyLength = asCollection.Count;
                unchecked
                {
                    this.WriteByte(( byte )((bodyLength >> 24) & 0xff));
                    this.WriteByte(( byte )((bodyLength >> 16) & 0xff));
                    this.WriteByte(( byte )((bodyLength >> 8) & 0xff));
                    this.WriteByte(( byte )(bodyLength & 0xff));
                }

                writeBody(asCollection, options);
            }
        }