コード例 #1
0
ファイル: GenericValueDeserializer.cs プロジェクト: vebin/BD2
 public override object Deserialize(System.IO.BinaryReader binaryReader)
 {
     bool hasValue = binaryReader.ReadBoolean ();
     if (!hasValue)
         return null;
     int typeID = binaryReader.ReadByte ();
     switch (typeID) {
     case 1:
         return binaryReader.ReadBoolean ();
     case 2:
         return binaryReader.ReadByte ();
     case 128:
         return binaryReader.ReadSByte ();
     case 3:
         return binaryReader.ReadInt16 ();
     case 129:
         return binaryReader.ReadUInt16 ();
     case 4:
         return binaryReader.ReadInt32 ();
     case 130:
         return binaryReader.ReadUInt32 ();
     case 5:
         return binaryReader.ReadInt64 ();
     case 131:
         return binaryReader.ReadUInt64 ();
     case 9:
         return binaryReader.ReadDouble ();
     case 16:
         return binaryReader.ReadString ();
     case 144:
         return binaryReader.ReadChar ();
     case 24:
         return new DateTime (binaryReader.ReadInt64 ());
     case 32:
         return new Guid (binaryReader.ReadBytes (16));
     case 36:
         return binaryReader.ReadBytes (binaryReader.ReadInt32 ());
     case 37:
         {
             int count = binaryReader.ReadInt32 ();
             string[] r = new string[count];
             for (int n = 0; n != count; n++)
                 r [n] = binaryReader.ReadString ();
             return r;
         }
     case 38:
         {
             int count = binaryReader.ReadInt32 ();
             long[] r = new long[count];
             for (int n = 0; n != count; n++)
                 r [n] = binaryReader.ReadInt64 ();
             return r;
         }
     default:
         throw new Exception (string.Format ("Serialization for type <{0}> is not supported", typeID));
     }
 }
コード例 #2
0
ファイル: FLCChunkByteRun.cs プロジェクト: CAMongrel/FLCLib
        protected override void ReadFromStream(System.IO.BinaryReader reader)
        {
            base.ReadFromStream(reader);

            PixelData = new byte[OwnerFile.Width * OwnerFile.Height];

            int pixelDataPointer = 0;

            for (int line = 0; line < OwnerFile.Height; line++)
            {
                byte packetCnt = reader.ReadByte();
                // Ignore packet count and just uncompress

                int uncompressedWidth = 0;

                while (uncompressedWidth < OwnerFile.Width)
                {
                    sbyte controlByte = reader.ReadSByte();
                    if (controlByte < 0)
                    {
                        byte copyCount = (byte)-controlByte;
                        uncompressedWidth += copyCount;
                        for (int i = 0; i < copyCount; i++)
                        {
                            PixelData[pixelDataPointer++] = reader.ReadByte();
                        }
                    }
                    else
                    {
                        uncompressedWidth += controlByte;
                        byte dataByte = reader.ReadByte();
                        for (int i = 0; i < controlByte; i++)
                            PixelData[pixelDataPointer++] = dataByte;
                    }
                }
            }
        }
コード例 #3
0
ファイル: XRC.cs プロジェクト: scott-t/TLJViewer
        public static string readResID(System.IO.BinaryReader data)
        {
            string ret = "";
            int size = data.ReadInt32();
            ret += " Node ID [" + size + "]\n";

            for (int i = 0; i < size; ++i)
            {
                ret += "     idx " + i + ": " + String.Format("0x{0:X2}, 0x{1:X2}", data.ReadSByte(), data.ReadInt16()) + "\n";
            }

            return ret;
        }
コード例 #4
0
 /// <summary>
 /// Reads a 8-bit signed integer
 /// </summary>
 public static void Read( System.IO.BinaryReader reader, out sbyte val )
 {
     val = reader.ReadSByte( );
 }