示例#1
0
        public Task WriteToAsync(RedisSocket socket, bool flush = true)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            Action <Stream> action = (stream) =>
            {
                using (var writer = new RedisStreamWriter(stream, flush))
                {
                    WriteTo(writer);
                }
            };

            return(action.InvokeAsync(socket.GetBufferedStream()));
        }
示例#2
0
        public void WriteTo(RedisSocket socket, bool flush = true)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            var stream = socket.GetBufferedStream();

            if (!stream.CanWrite)
            {
                throw new ArgumentException("Can not write to closed stream", "stream");
            }

            using (var writer = new RedisStreamWriter(stream, flush))
            {
                WriteTo(writer);
            }
        }