Пример #1
0
        // #end example

        // #example: Read the StringBuilder
        public object Read(IReadContext readContext)
        {
            int length = readContext.ReadInt();
            byte[] data = new byte[length];
            readContext.ReadBytes(data);
            return new StringBuilder(Encoding.UTF8.GetString(data));
        }
Пример #2
0
 public override object Read(IReadContext context)
 {
     byte[] bytes = new byte[2];
     context.ReadBytes(bytes);
     return (ushort)(
              bytes[1] & 255 |
             (bytes[0] & 255) << 8
         );
 }
Пример #3
0
 public override object Read(IReadContext context)
 {
     byte[] bytes = new byte[4];
     context.ReadBytes(bytes);
     return (uint)(
              bytes[3] & 255        | 
             (bytes[2] & 255) << 8  | 
             (bytes[1] & 255) << 16 | 
             (bytes[0] & 255) << 24
         );
 }
Пример #4
0
 public override object Read(IReadContext context)
 {
     byte[] bytes = new byte[4];
     context.ReadBytes(bytes);
     return((uint)(
                bytes[3] & 255 |
                (bytes[2] & 255) << 8 |
                    (bytes[1] & 255) << 16 |
                    (bytes[0] & 255) << 24
                ));
 }
Пример #5
0
 public override object Read(IReadContext context)
 {
     var bytes = new byte[8];
     context.ReadBytes(bytes);
     return (ulong) bytes[7] & 255 |
            (ulong) (bytes[6] & 255) << 8 |
            (ulong) (bytes[5] & 255) << 16 |
            (ulong) (bytes[4] & 255) << 24 |
            (ulong) (bytes[3] & 255) << 32 |
            (ulong) (bytes[2] & 255) << 40 |
            (ulong) (bytes[1] & 255) << 48 |
            (ulong) (bytes[0] & 255) << 56;
 }
Пример #6
0
        public override object Read(IReadContext context)
        {
            var bytes = new byte[8];

            context.ReadBytes(bytes);
            return((ulong)bytes[7] & 255 |
                   (ulong)(bytes[6] & 255) << 8 |
                   (ulong)(bytes[5] & 255) << 16 |
                   (ulong)(bytes[4] & 255) << 24 |
                   (ulong)(bytes[3] & 255) << 32 |
                   (ulong)(bytes[2] & 255) << 40 |
                   (ulong)(bytes[1] & 255) << 48 |
                   (ulong)(bytes[0] & 255) << 56);
        }
Пример #7
0
 public override object Read(IReadContext context)
 {
     byte[] bytes = new byte[16];
     int[] ints = new int[4];
     int offset = 4;
     context.ReadBytes(bytes);
     for (int i = 0; i < 4; i++)
     {
         ints[i] =   (
                      bytes[--offset] & 255 | 
                     (bytes[--offset] & 255) << 8 | 
                     (bytes[--offset] & 255) << 16 | 
                     (bytes[--offset] & 255) << 24
                     );
         offset += 8;
     }
     return new Decimal(ints);
 }
Пример #8
0
        public override object Read(IReadContext context)
        {
            byte[] bytes  = new byte[16];
            int[]  ints   = new int[4];
            int    offset = 4;

            context.ReadBytes(bytes);
            for (int i = 0; i < 4; i++)
            {
                ints[i] = (
                    bytes[--offset] & 255 |
                    (bytes[--offset] & 255) << 8 |
                        (bytes[--offset] & 255) << 16 |
                        (bytes[--offset] & 255) << 24
                    );
                offset += 8;
            }
            return(new Decimal(ints));
        }
Пример #9
0
		protected void ReadInto(IReadContext context, ArrayInfo info, object array)
		{
			if (array == null)
			{
				return;
			}
			if (HandleAsByteArray(array))
			{
				context.ReadBytes((byte[])array);
				// byte[] performance optimisation
				return;
			}
			if (HasNullBitmap(info))
			{
				BitMap4 nullBitMap = ReadNullBitmap(context, info.ElementCount());
				for (int i = 0; i < info.ElementCount(); i++)
				{
					object obj = nullBitMap.IsTrue(i) ? null : context.ReadObject(_handler);
					ArrayReflector(Container(context)).Set(array, i, obj);
				}
			}
			else
			{
				for (int i = 0; i < info.ElementCount(); i++)
				{
					ArrayReflector(Container(context)).Set(array, i, context.ReadObject(_handler));
				}
			}
		}