public static string ToHexString <T>(T obj, IEncoding <T> encoding) { using (OrientedBitStream inMemoryBitStream = CreateSuitableInMemoryBitStream()) { IBitWriter suitableBitWriter = inMemoryBitStream.CreateSuitableBitWriter(); encoding.Encode(obj, suitableBitWriter); inMemoryBitStream.Position = 0L; byte[] numArray = new byte[inMemoryBitStream.Length / 8L]; inMemoryBitStream.Read(numArray, 0, numArray.Length); return(numArray.ToHexString()); } }
public static IBitWriter CreateSuitableBitWriter(this Stream stream) { OrientedBitStream suitableBitStream = stream.CreateSuitableBitStream(); return(new OrientedEndianBitWriter(CreateSuitableBitConverter(), suitableBitStream)); }