Example #1
0
        internal RedisChannel AsRedisChannel(byte[] channelPrefix, RedisChannel.PatternMode mode)
        {
            switch (Type)
            {
            case ResultType.SimpleString:
            case ResultType.BulkString:
                if (channelPrefix == null)
                {
                    return(new RedisChannel(GetBlob(), mode));
                }
                if (StartsWith(channelPrefix))
                {
                    byte[] copy = Payload.Slice(channelPrefix.Length).ToArray();
                    return(new RedisChannel(copy, mode));
                }
                return(default(RedisChannel));

            default:
                throw new InvalidCastException("Cannot convert to RedisChannel: " + Type);
            }
        }
Example #2
0
        internal RedisChannel AsRedisChannel(byte[] channelPrefix, RedisChannel.PatternMode mode)
        {
            switch (Type)
            {
            case ResultType.SimpleString:
            case ResultType.BulkString:
                if (channelPrefix == null)
                {
                    return(new RedisChannel(GetBlob(), mode));
                }
                if (AssertStarts(channelPrefix))
                {
                    var src = (byte[])arr;

                    byte[] copy = new byte[count - channelPrefix.Length];
                    Buffer.BlockCopy(src, offset + channelPrefix.Length, copy, 0, copy.Length);
                    return(new RedisChannel(copy, mode));
                }
                return(default(RedisChannel));

            default:
                throw new InvalidCastException("Cannot convert to RedisChannel: " + Type);
            }
        }
Example #3
0
 public RedisSubKey(string key, RedisChannel.PatternMode patternMode)
 {
     Key         = key;
     PatternMode = patternMode;
 }
Example #4
0
 public RedisChannel GetChannel(int index, RedisChannel.PatternMode mode)
 => _inner[index].AsRedisChannel(null, mode);