public string Read() { var isIp = ReadOneBit(); if (isIp) { var len = ReadOneBit() ? BytesPerIpv6 : BytesPerIpv4; var cache = bytesWriter.Read(len); return(new IPAddress(cache).ToString()); } else { var cache = bytesWriter.Read(); return(Encoding.UTF8.GetString(cache)); } }
public T Read <T>() { lock (rbsWriteLock) { var typeName = typeof(T).Name; switch (typeof(T).Name) { case nameof(Int32): return((T)(numberWriter.Read(BitsPerInt) as object)); case nameof(Boolean): return((T)((rawBitStream.Read() == true) as object)); case nameof(Guid): return((T)(uuidsWriter.Read() as object)); case nameof(String): var cache = bytesWriter.Read(); var result = Encoding.UTF8.GetString(cache); return((T)(result as object)); default: throw new NotSupportedException($"Not support type {typeName}"); } } }
public Guid Read() { var uuid = bytesWriter.Read(BytesPerUuid); return(new Guid(uuid)); }