public static void Write(Stream stream, string value) { if (value == null) { NetworkByteOrderConverter.WriteInt32(stream, -1); } else { byte[] buffer = Encoding.UTF8.GetBytes(value); NetworkByteOrderConverter.WriteInt32(stream, buffer.Length); stream.Write(buffer, 0, buffer.Length); } }
public static string ReadString(Stream stream) { string result; int length = NetworkByteOrderConverter.ToInt32(stream); if (length < 0) { result = null; } else { byte[] buffer = new byte[length]; stream.Read(buffer, 0, length); result = Encoding.UTF8.GetString(buffer); } return(result); }
public static void Write(Stream stream, long value) { NetworkByteOrderConverter.WriteInt64(stream, value); }
public static void Write(Stream stream, int value) { NetworkByteOrderConverter.WriteInt32(stream, value); }
public static long ReadInt64(Stream stream) { return(NetworkByteOrderConverter.ToInt64(stream)); }
public static int ReadInt32(Stream stream) { return(NetworkByteOrderConverter.ToInt32(stream)); }