BinaryWriterWithEndianConversion.cs 1.2 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 BinaryWriterWithEndianConversion : BinaryWriter
  7. {
  8. public BinaryWriterWithEndianConversion(Stream output, Encoding encoding, bool leaveOpen) : base(output,
  9. encoding, leaveOpen)
  10. {
  11. }
  12. public override void Write(decimal value) => base.Write(value.EndianConvert());
  13. public override void Write(double value) => base.Write(value.EndianConvert());
  14. public override void Write(short value) => base.Write(value.EndianConvert());
  15. public override void Write(int value) => base.Write(value.EndianConvert());
  16. public override void Write(long value) => base.Write(value.EndianConvert());
  17. public override void Write(float value) => base.Write(value.EndianConvert());
  18. public override void Write(ushort value) => base.Write(value.EndianConvert());
  19. public override void Write(uint value) => base.Write(value.EndianConvert());
  20. public override void Write(ulong value) => base.Write(value.EndianConvert());
  21. }
  22. }