コード例 #1
0
 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);
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 public static void Write(Stream stream, long value)
 {
     NetworkByteOrderConverter.WriteInt64(stream, value);
 }
コード例 #4
0
 public static void Write(Stream stream, int value)
 {
     NetworkByteOrderConverter.WriteInt32(stream, value);
 }
コード例 #5
0
 public static long ReadInt64(Stream stream)
 {
     return(NetworkByteOrderConverter.ToInt64(stream));
 }
コード例 #6
0
 public static int ReadInt32(Stream stream)
 {
     return(NetworkByteOrderConverter.ToInt32(stream));
 }