Ejemplo n.º 1
0
        public void Pack(Packer stream, object obj)
        {
            var e    = obj as System.Enum;
            var type = e.GetType().GetEnumUnderlyingType();

            if (type == typeof(int))
            {
                stream.WriteByte((byte)TypeValue.Int32);
                var ser = new Int32Serializer();
                ser.Pack(stream, obj);
            }
            else if (type == typeof(short))
            {
                stream.WriteByte((byte)TypeValue.Int16);
                var ser = new Int16Serializer();
                ser.Pack(stream, obj);
            }
            else if (type == typeof(long))
            {
                stream.WriteByte((byte)TypeValue.Int64);
                var ser = new Int64Serializer();
                ser.Pack(stream, obj);
            }
            else if (type == typeof(uint))
            {
                stream.WriteByte((byte)TypeValue.UInt32);
                var ser = new UInt32Serializer();
                ser.Pack(stream, obj);
            }
            else if (type == typeof(ushort))
            {
                stream.WriteByte((byte)TypeValue.UInt16);
                var ser = new UInt16Serializer();
                ser.Pack(stream, obj);
            }
            else if (type == typeof(ulong))
            {
                stream.WriteByte((byte)TypeValue.UInt64);
                var ser = new UInt64Serializer();
                ser.Pack(stream, obj);
            }
            else if (type == typeof(byte))
            {
                stream.WriteByte((byte)TypeValue.Byte);
                var ser = new ByteSerializer();
                ser.Pack(stream, obj);
            }
            else if (type == typeof(sbyte))
            {
                stream.WriteByte((byte)TypeValue.SByte);
                var ser = new SByteSerializer();
                ser.Pack(stream, obj);
            }
            else
            {
                stream.WriteByte((byte)TypeValue.String);
                var ser = new StringSerializer();
                ser.Pack(stream, obj);
            }
        }
Ejemplo n.º 2
0
        public void Pack(Packer packer, object obj)
        {
            var int32 = new UInt32Serializer();

            int32.Pack(packer, (uint)(ViewId)obj);
        }