static Endian() { Little = new Endian(); Big = new Endian(); Native = BitConverter.IsLittleEndian ? Little : Big; NonNative = BitConverter.IsLittleEndian ? Big : Little; }
/// <summary> /// Creates a BinaryWriter to write to the stream managed by <paramref name="writer"/> /// using the provided Endian setting. <paramref name="marker"/> is written to the /// stream to mark the Endian setting used. /// </summary> public static BinaryWriter WriteEndianMarker(this BinaryWriter writer, Endian endian, uint marker) { BinaryWriter result = writer; if (endian != Endian.Native) { var endianWriter = new EndianWriter(writer) {Endian = endian}; result = endianWriter; } writer.Write(marker); return result; }
/// <summary> /// Creates a converter for changing data from the current /// Endian setting to the target Endian setting. /// </summary> public EndianConverter To(Endian target) { return EndianConverter.Create(this != target); }