Example #1
0
        /// <summary>
        /// Serialize an Int32
        /// </summary>
        /// <param name="i">The Int</param>
        /// <returns>The Packet</returns>
        public static SerializedPacket SerializeInt(int i)
        {
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.Integer32Id;
            packet.Add((byte)((i >> 0) & 0xFF));
            packet.Add((byte)((i >> 8) & 0xFF));
            packet.Add((byte)((i >> 16) & 0xFF));
            packet.Add((byte)((i >> 24) & 0xFF));
            return(packet);
        }
Example #2
0
        /// <summary>
        /// Serialize a Rectangle
        /// </summary>
        /// <param name="r">The rectangle</param>
        /// <returns>The packet</returns>
        public static SerializedPacket SerializeRectangle(System.Drawing.Rectangle r)
        {
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.RectangleId;
            packet.Add(SerializeInt(r.X));
            packet.Add(SerializeInt(r.Y));
            packet.Add(SerializeInt(r.Width));
            packet.Add(SerializeInt(r.Height));
            return(packet);
        }
Example #3
0
        /// <summary>
        /// Serialize an IPEndPoint
        /// </summary>
        /// <param name="ep">The end point</param>
        /// <returns>The packet</returns>
        public static SerializedPacket SerializeIPEndPoint(System.Net.IPEndPoint ep)
        {
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.IPEndPointId;
            // Pack the Data
            packet.Add(SerializeInt((int)ep.AddressFamily));
            packet.Add(SerializeInt(ep.Port));
//            packet.Add( SerializeLong( ep.Address.ScopeId ) );
            packet.Add(SerializeByteArray(ep.Address.GetAddressBytes()));
            return(packet);
        }
Example #4
0
        /// <summary>
        /// Serialize a Color struct
        /// </summary>
        /// <param name="c">The color</param>
        /// <returns>The packet</returns>
        public static SerializedPacket SerializeColor(System.Drawing.Color c)
        {
            if (c.IsEmpty)
            {
                return(NullPacket(PacketTypes.ColorId));
            }
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.ColorId;
            packet.Add(c.A);
            packet.Add(c.R);
            packet.Add(c.G);
            packet.Add(c.B);
            return(packet);
        }
Example #5
0
        /// <summary>
        /// Serialize a GUID
        /// </summary>
        /// <param name="g">The guid</param>
        /// <returns>The packet</returns>
        public static SerializedPacket SerializeMD5(Guid g)
        {
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.ByteArrayClassId;
            packet.Add(g.ToByteArray());
            return(packet);
        }
Example #6
0
        /// <summary>
        /// Serialize a Float
        /// </summary>
        /// <param name="f">The float</param>
        /// <returns>The Packet</returns>
        public static SerializedPacket SerializeFloat(float f)
        {
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.FloatId;
            packet.Add(BitConverter.GetBytes(f));
            return(packet);
        }
Example #7
0
        /// <summary>
        /// Serialize a Boolean Value
        /// </summary>
        /// <param name="i"></param>
        /// <returns></returns>
        public static SerializedPacket SerializeBool(bool i)
        {
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.BoolId;
            packet.Add((i) ? (byte)1 : (byte)0);
            return(packet);
        }
Example #8
0
        /// <summary>
        /// Serialize a ULong
        /// </summary>
        /// <param name="i">The ULong</param>
        /// <returns>The Packet</returns>
        public static SerializedPacket SerializeULong(ulong i)
        {
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.ULongId;
            packet.Add((byte)((i >> 0) & 0xFF));
            packet.Add((byte)((i >> 8) & 0xFF));
            packet.Add((byte)((i >> 16) & 0xFF));
            packet.Add((byte)((i >> 24) & 0xFF));
            packet.Add((byte)((i >> 32) & 0xFF));
            packet.Add((byte)((i >> 40) & 0xFF));
            packet.Add((byte)((i >> 48) & 0xFF));
            packet.Add((byte)((i >> 56) & 0xFF));
            return(packet);
        }
Example #9
0
        /// <summary>
        /// Serialize an Int64
        /// </summary>
        /// <param name="i">The Int64</param>
        /// <returns>The Packet</returns>
        public static SerializedPacket SerializeInt64(Int64 i)
        {
            SerializedPacket packet = new SerializedPacket();

            packet.Type = PacketTypes.Integer64Id;
            packet.Add((byte)((i >> 0) & 0xFF));
            packet.Add((byte)((i >> 8) & 0xFF));
            packet.Add((byte)((i >> 16) & 0xFF));
            packet.Add((byte)((i >> 24) & 0xFF));
            packet.Add((byte)((i >> 32) & 0xFF));
            packet.Add((byte)((i >> 40) & 0xFF));
            packet.Add((byte)((i >> 48) & 0xFF));
            packet.Add((byte)((i >> 56) & 0xFF));
            return(packet);
        }
 /// <summary>
 /// Serialize a GUID
 /// </summary>
 /// <param name="g">The guid</param>
 /// <returns>The packet</returns>
 public static SerializedPacket SerializeMD5(Guid g)
 {
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.ByteArrayClassId;
     packet.Add(g.ToByteArray());
     return packet;
 }
 /// <summary>
 /// Serialize an IPEndPoint
 /// </summary>
 /// <param name="ep">The end point</param>
 /// <returns>The packet</returns>
 public static SerializedPacket SerializeIPEndPoint( System.Net.IPEndPoint ep )
 {
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.IPEndPointId;
     // Pack the Data
     packet.Add( SerializeInt( (int)ep.AddressFamily ) );
     packet.Add( SerializeInt( ep.Port ) );
     //            packet.Add( SerializeLong( ep.Address.ScopeId ) );
     packet.Add( SerializeByteArray( ep.Address.GetAddressBytes() ) );
     return packet;
 }
 /// <summary>
 /// Serialize an Int64
 /// </summary>
 /// <param name="i">The Int64</param>
 /// <returns>The Packet</returns>
 public static SerializedPacket SerializeInt64( Int64 i )
 {
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.Integer64Id;
     packet.Add( (byte)((i >> 0) & 0xFF) );
     packet.Add( (byte)((i >> 8) & 0xFF) );
     packet.Add( (byte)((i >> 16) & 0xFF) );
     packet.Add( (byte)((i >> 24) & 0xFF) );
     packet.Add( (byte)((i >> 32) & 0xFF) );
     packet.Add( (byte)((i >> 40) & 0xFF) );
     packet.Add( (byte)((i >> 48) & 0xFF) );
     packet.Add( (byte)((i >> 56) & 0xFF) );
     return packet;
 }
 /// <summary>
 /// Serialize an Int32
 /// </summary>
 /// <param name="i">The Int</param>
 /// <returns>The Packet</returns>
 public static SerializedPacket SerializeInt( int i )
 {
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.Integer32Id;
     packet.Add( (byte)((i >> 0) & 0xFF) );
     packet.Add( (byte)((i >> 8) & 0xFF) );
     packet.Add( (byte)((i >> 16) & 0xFF) );
     packet.Add( (byte)((i >> 24) & 0xFF) );
     return packet;
 }
 /// <summary>
 /// Serialize a Float
 /// </summary>
 /// <param name="f">The float</param>
 /// <returns>The Packet</returns>
 public static SerializedPacket SerializeFloat( float f )
 {
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.FloatId;
     packet.Add( BitConverter.GetBytes( f ) );
     return packet;
 }
 /// <summary>
 /// Serialize a Color struct
 /// </summary>
 /// <param name="c">The color</param>
 /// <returns>The packet</returns>
 public static SerializedPacket SerializeColor( System.Drawing.Color c )
 {
     if( c.IsEmpty ) return NullPacket( PacketTypes.ColorId );
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.ColorId;
     packet.Add( c.A );
     packet.Add( c.R );
     packet.Add( c.G );
     packet.Add( c.B );
     return packet;
 }
 /// <summary>
 /// Serialize a Boolean Value
 /// </summary>
 /// <param name="i"></param>
 /// <returns></returns>
 public static SerializedPacket SerializeBool( bool i )
 {
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.BoolId;
     packet.Add( (i) ? (byte)1 : (byte)0 );
     return packet;
 }
Example #17
0
 public SerializedPacket Serialize()
 {
     SerializedPacket p = new SerializedPacket( this.GetClassId() );
     p.Add( SerializedPacket.SerializeGuid( this.m_OwnerId ) );
     p.Add( SerializedPacket.SerializeString( this.m_ResultString ) );
     return p;
 }
 /// <summary>
 /// Serialize a Rectangle
 /// </summary>
 /// <param name="r">The rectangle</param>
 /// <returns>The packet</returns>
 public static SerializedPacket SerializeRectangle( System.Drawing.Rectangle r )
 {
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.RectangleId;
     packet.Add( SerializeInt( r.X ) );
     packet.Add( SerializeInt( r.Y ) );
     packet.Add( SerializeInt( r.Width ) );
     packet.Add( SerializeInt( r.Height ) );
     return packet;
 }
 public SerializedPacket Serialize()
 {
     SerializedPacket p = new SerializedPacket( this.GetClassId() );
     p.Add( SerializedPacket.SerializeGuid( this.id_ ) );
     p.Add( SerializedPacket.SerializeInt( (int)this.submission_status_ ) );
     p.Add( SerializedPacket.SerializeString( this.role_ ) );
     return p;
 }
 /// <summary>
 /// Serialize a ULong
 /// </summary>
 /// <param name="i">The ULong</param>
 /// <returns>The Packet</returns>
 public static SerializedPacket SerializeULong( ulong i )
 {
     SerializedPacket packet = new SerializedPacket();
     packet.Type = PacketTypes.ULongId;
     packet.Add( (byte)((i >> 0) & 0xFF) );
     packet.Add( (byte)((i >> 8) & 0xFF) );
     packet.Add( (byte)((i >> 16) & 0xFF) );
     packet.Add( (byte)((i >> 24) & 0xFF) );
     packet.Add( (byte)((i >> 32) & 0xFF) );
     packet.Add( (byte)((i >> 40) & 0xFF) );
     packet.Add( (byte)((i >> 48) & 0xFF) );
     packet.Add( (byte)((i >> 56) & 0xFF) );
     return packet;
 }
Example #21
0
 public SerializedPacket Serialize()
 {
     SerializedPacket p = new SerializedPacket( this.GetClassId() );
     p.Add( SerializedPacket.SerializeGuid( this.m_Id ) );
     p.Add( SerializedPacket.SerializeGuid( this.m_OriginalSlideId ) );
     p.Add( SerializedPacket.SerializeInt( (int)this.m_QuickPollStyle ) );
     p.Add( SerializedPacket.SerializeBool( this.m_Changed ) );
     p.Add( SerializedPacket.SerializeInt( this.m_Choices.Length ) );
     foreach( string s in this.m_Choices ) {
         p.Add( SerializedPacket.SerializeString( s ) );
     }
     p.Add( SerializedPacket.SerializeInt( this.m_QuickPollResults.Count ) );
     foreach( QuickPollResultModel res in this.m_QuickPollResults ) {
         p.Add( res.Serialize() );
     }
     return p;
 }