| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- using System.Text;
- using System.IO;
- namespace DragonBones
- {
- internal class BinaryDataReader : BinaryReader
- {
- private int i;
- private int readLength;
- internal BinaryDataReader(Stream stream) : base(stream)
- {
- }
- internal BinaryDataReader(Stream stream, Encoding encoding) : base(stream, encoding)
- {
- }
- public virtual void Seek(int offset, SeekOrigin origin = SeekOrigin.Current)
- {
- if (offset == 0)
- {
- return;
- }
- BaseStream.Seek(offset, origin);
- }
- public virtual bool[] ReadBooleans(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- bool[] flagArray = new bool[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- flagArray[this.i] = base.ReadBoolean();
- this.i++;
- }
- return flagArray;
- }
- public virtual byte[] ReadBytes(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- byte[] buffer = new byte[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- buffer[this.i] = base.ReadByte();
- this.i++;
- }
- return buffer;
- }
- public virtual char[] ReadChars(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- char[] chArray = new char[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- chArray[this.i] = base.ReadChar();
- this.i++;
- }
- return chArray;
- }
- public virtual decimal[] ReadDecimals(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- decimal[] numArray = new decimal[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadDecimal();
- this.i++;
- }
- return numArray;
- }
- public virtual double[] ReadDoubles(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- double[] numArray = new double[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadDouble();
- this.i++;
- }
- return numArray;
- }
- public virtual short[] ReadInt16s(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- short[] numArray = new short[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadInt16();
- this.i++;
- }
- return numArray;
- }
- public virtual int[] ReadInt32s(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- int[] numArray = new int[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadInt32();
- this.i++;
- }
- return numArray;
- }
- public virtual long[] ReadInt64s(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- long[] numArray = new long[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadInt64();
- this.i++;
- }
- return numArray;
- }
- public virtual sbyte[] ReadSBytes(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- sbyte[] numArray = new sbyte[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadSByte();
- this.i++;
- }
- return numArray;
- }
- public virtual float[] ReadSingles(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- float[] numArray = new float[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadSingle();
- this.i++;
- }
- return numArray;
- }
- public virtual string[] ReadStrings(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- string[] strArray = new string[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- strArray[this.i] = base.ReadString();
- this.i++;
- }
- return strArray;
- }
- public virtual ushort[] ReadUInt16s(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- ushort[] numArray = new ushort[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadUInt16();
- this.i++;
- }
- return numArray;
- }
- public virtual uint[] ReadUInt32s(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- uint[] numArray = new uint[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadUInt32();
- this.i++;
- }
- return numArray;
- }
- public virtual ulong[] ReadUInt64s(int offset, int readLength)
- {
- Seek(offset);
- this.readLength = readLength;
- ulong[] numArray = new ulong[this.readLength];
- this.i = 0;
- while (this.i < this.readLength)
- {
- numArray[this.i] = base.ReadUInt64();
- this.i++;
- }
- return numArray;
- }
- private long Length
- {
- get
- {
- return this.BaseStream.Length;
- }
- }
- }
- }
|