BinaryReaderWithEndianConversion.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using System.IO;
  2. using System.Text;
  3. using TBL.CSharp.Serialization.Marshal;
  4. namespace TBL.CSharp.Serialization.Utilities
  5. {
  6. public class BinaryReaderWithEndianConversion : BinaryReader
  7. {
  8. public BinaryReaderWithEndianConversion(Stream input, Encoding encoding, bool leaveOpen) :
  9. base(input, encoding, leaveOpen)
  10. {
  11. }
  12. public override decimal ReadDecimal() => base.ReadDecimal().EndianConvert();
  13. public override double ReadDouble() => base.ReadDouble().EndianConvert();
  14. public override short ReadInt16() => base.ReadInt16().EndianConvert();
  15. public override int ReadInt32() => base.ReadInt32().EndianConvert();
  16. public override long ReadInt64() => base.ReadInt64().EndianConvert();
  17. public override float ReadSingle() => base.ReadSingle().EndianConvert();
  18. public override ushort ReadUInt16() => base.ReadUInt16().EndianConvert();
  19. public override uint ReadUInt32() => base.ReadUInt32().EndianConvert();
  20. public override ulong ReadUInt64() => base.ReadUInt64().EndianConvert();
  21. }
  22. }