Pack() 공개 메소드

Pack nullable Boolean value.
public Pack ( System.Boolean value ) : Packer
value System.Boolean Value to serialize.
리턴 Packer
예제 #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 );
		}
예제 #2
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);
 }
예제 #4
0
파일: Utils.cs 프로젝트: lbddk/ahzs-client
        public static bool MsgPackLuaTable(ref LuaTable luatable, ref Packer pker)
        {

            if (luatable == null)
            {
                pker = null;
                return false;
            }
            else
            {
                pker.PackMapHeader(luatable.Count);
            }
            foreach (var item in luatable)
            {
                //object key = item.Key;
                bool kFlag = luatable.IsKeyString(item.Key);
                if (kFlag)
                {
                    pker.PackRawHeader(item.Key.Length);
                    pker.PackRawBody(System.Text.Encoding.UTF8.GetBytes(item.Key));
                }
                else
                {
                    pker.Pack(double.Parse(item.Key.ToString()));
                }

                var valueType = item.Value.GetType();
                if (valueType == typeof(String))
                {

                    pker.PackRawHeader(item.Value.ToString().Length);
                    pker.PackRawBody(System.Text.Encoding.UTF8.GetBytes(item.Value.ToString()));
                }
                else if (valueType == typeof(LuaTable))
                {
                    LuaTable luaTbl = item.Value as LuaTable;
                    MsgPackLuaTable(ref luaTbl, ref pker);
                }
                else if (valueType == typeof(bool))
                {
                    pker.Pack(bool.Parse(item.Value.ToString()));
                }
                else
                {
                    pker.Pack(double.Parse(item.Value.ToString()));
                }
            }
            return true;
        }
		public void PackToMessage( Packer packer, PackingOptions options )
		{
			// Pack fields are here:
			// First, record total fields size.
			packer.PackArrayHeader( 2 );
			packer.Pack( this.Id );
			packer.Pack( 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 );
		}
예제 #6
0
 /// <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);
         }
     }
 }
예제 #7
0
        /// <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());
        }
예제 #8
0
 public void PackToMessage(Packer packer, PackingOptions options)
 {
     // 0xC3
     packer.Pack(true);
 }
예제 #9
0
 protected override void PackToMessageCore(Packer packer)
 {
     packer.PackArrayHeader(1);
     packer.Pack(_str);
 }
 public void PackToMessage(Packer packer, PackingOptions options)
 {
     packer.Pack(count);
     packer.PackString(data);
 }
예제 #11
0
			public void PackToMessage( Packer packer, PackingOptions options )
			{
				// 0xC3
				packer.Pack( true );
			}
예제 #12
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);
        }
 /// <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);
         }
     }
 }
예제 #14
0
        public void PackToMessage(Packer packer, PackingOptions options)
        {
            packer.Pack((byte)RequestType);

            PackToMessageCore(packer);
        }
        void Pack(Packer packer, object o)
        {
            if (o == null) {
                packer.PackNull();
                return;
            }

            if (o is int)
                packer.Pack ((int)o);
            else if (o is uint)
                packer.Pack ((uint)o);
            else if (o is float)
                packer.Pack ((float)o);
            else if (o is double)
                packer.Pack ((double)o);
            else if (o is long)
                packer.Pack ((long)o);
            else if (o is ulong)
                packer.Pack ((ulong)o);
            else if (o is bool)
                packer.Pack ((bool)o);
            else if (o is byte)
                packer.Pack ((byte)o);
            else if (o is sbyte)
                packer.Pack ((sbyte)o);
            else if (o is short)
                packer.Pack ((short)o);
            else if (o is ushort)
                packer.Pack ((ushort)o);
            else if (o is string)
                packer.PackString((string)o, Encoding.ASCII);
            else if (o is Dictionary<string, object>)
            {
                packer.PackMapHeader((o as Dictionary<string, object>).Count);

                foreach (var pair in (o as Dictionary<string, object>))
                {
                    Pack(packer, pair.Key);
                    Pack(packer, pair.Value);
                }

            }
            else if (o is string[])
            {
                packer.PackArrayHeader((o as string[]).Length);

                foreach (var obj in (o as string[]))
                    packer.Pack(obj as string);
            }
            else
                throw new Exception("Cant handle type: " + o.GetType().Name);;
        }