void Clear()
        {
            clientName     = serviceName = password = tieBreaker = sslHost = configChannel = null;
            keepAlive      = syncTimeout = connectTimeout = writeBuffer = connectRetry = configCheckSeconds = defaultDatabase = null;
            allowAdmin     = abortOnConnectFail = highPrioritySocketThreads = resolveDns = ssl = preserveAsyncOrder = null;
            defaultVersion = null;
            endpoints.Clear();
            commandMap = null;

            CertificateSelection  = null;
            CertificateValidation = null;
            ChannelPrefix         = default(RedisChannel);
            SocketManager         = null;
        }
        void Clear()
        {
            clientName = serviceName = password = tieBreaker = sslHost = configChannel = null;
            keepAlive = syncTimeout = connectTimeout = writeBuffer = connectRetry = configCheckSeconds = defaultDatabase = null;
            allowAdmin = abortOnConnectFail = highPrioritySocketThreads = resolveDns = ssl = null;
            defaultVersion = null;
            endpoints.Clear();
            commandMap = null;

            CertificateSelection = null;
            CertificateValidation = null;            
            ChannelPrefix = default(RedisChannel);
            SocketManager = null;
        }
        private void DoParse(string configuration, bool ignoreUnknown)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (string.IsNullOrWhiteSpace(configuration))
            {
                throw new ArgumentException("is empty", configuration);
            }

            Clear();

            // break it down by commas
            var arr = configuration.Split(StringSplits.Comma);
            Dictionary <string, string> map = null;

            foreach (var paddedOption in arr)
            {
                var option = paddedOption.Trim();

                if (string.IsNullOrWhiteSpace(option))
                {
                    continue;
                }

                // check for special tokens
                int idx = option.IndexOf('=');
                if (idx > 0)
                {
                    var key   = option.Substring(0, idx).Trim();
                    var value = option.Substring(idx + 1).Trim();

                    switch (OptionKeys.TryNormalize(key))
                    {
                    case OptionKeys.SyncTimeout:
                        SyncTimeout = OptionKeys.ParseInt32(key, value, minValue: 1);
                        break;

                    case OptionKeys.AllowAdmin:
                        AllowAdmin = OptionKeys.ParseBoolean(key, value);
                        break;

                    case OptionKeys.AbortOnConnectFail:
                        AbortOnConnectFail = OptionKeys.ParseBoolean(key, value);
                        break;

                    case OptionKeys.ResolveDns:
                        ResolveDns = OptionKeys.ParseBoolean(key, value);
                        break;

                    case OptionKeys.ServiceName:
                        ServiceName = value;
                        break;

                    case OptionKeys.ClientName:
                        ClientName = value;
                        break;

                    case OptionKeys.ChannelPrefix:
                        ChannelPrefix = value;
                        break;

                    case OptionKeys.ConfigChannel:
                        ConfigurationChannel = value;
                        break;

                    case OptionKeys.KeepAlive:
                        KeepAlive = OptionKeys.ParseInt32(key, value);
                        break;

                    case OptionKeys.ConnectTimeout:
                        ConnectTimeout = OptionKeys.ParseInt32(key, value);
                        break;

                    case OptionKeys.ConnectRetry:
                        ConnectRetry = OptionKeys.ParseInt32(key, value);
                        break;

                    case OptionKeys.ConfigCheckSeconds:
                        ConfigCheckSeconds = OptionKeys.ParseInt32(key, value);
                        break;

                    case OptionKeys.Version:
                        DefaultVersion = OptionKeys.ParseVersion(key, value);
                        break;

                    case OptionKeys.Password:
                        Password = value;
                        break;

                    case OptionKeys.TieBreaker:
                        TieBreaker = value;
                        break;

                    case OptionKeys.Ssl:
                        Ssl = OptionKeys.ParseBoolean(key, value);
                        break;

                    case OptionKeys.SslHost:
                        SslHost = value;
                        break;

                    case OptionKeys.HighPrioritySocketThreads:
                        HighPrioritySocketThreads = OptionKeys.ParseBoolean(key, value);
                        break;

                    case OptionKeys.WriteBuffer:
                        WriteBuffer = OptionKeys.ParseInt32(key, value);
                        break;

                    case OptionKeys.Proxy:
                        Proxy = OptionKeys.ParseProxy(key, value);
                        break;

                    case OptionKeys.ResponseTimeout:
                        ResponseTimeout = OptionKeys.ParseInt32(key, value, minValue: 1);
                        break;

                    case OptionKeys.DefaultDatabase:
                        defaultDatabase = OptionKeys.ParseInt32(key, value);
                        break;

                    case OptionKeys.PreserveAsyncOrder:
                        PreserveAsyncOrder = OptionKeys.ParseBoolean(key, value);
                        break;

#if !CORE_CLR
                    case OptionKeys.SslProtocols:
                        SslProtocols = OptionKeys.ParseSslProtocols(key, value);
                        break;
#endif
                    default:
                        if (!string.IsNullOrEmpty(key) && key[0] == '$')
                        {
                            RedisCommand cmd;
                            var          cmdName = option.Substring(1, idx - 1);
                            if (Enum.TryParse(cmdName, true, out cmd))
                            {
                                if (map == null)
                                {
                                    map = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                                }
                                map[cmdName] = value;
                            }
                        }
                        else
                        {
                            if (!ignoreUnknown)
                            {
                                OptionKeys.Unknown(key);
                            }
                        }
                        break;
                    }
                }
                else
                {
                    var ep = Format.TryParseEndPoint(option);
                    if (ep != null && !endpoints.Contains(ep))
                    {
                        endpoints.Add(ep);
                    }
                }
            }
            if (map != null && map.Count != 0)
            {
                CommandMap = CommandMap.Create(map);
            }
        }
Exemplo n.º 4
0
 internal override void CheckCommands(CommandMap commandMap)
 {
     commandMap.AssertAvailable(hashField.IsNull ? RedisCommand.GET : RedisCommand.HGET);
 }
Exemplo n.º 5
0
 internal abstract void CheckCommands(CommandMap commandMap);
Exemplo n.º 6
0
 internal override void CheckCommands(CommandMap commandMap)
 {
     commandMap.AssertAvailable(cmd);
 }
Exemplo n.º 7
0
 internal override void CheckCommands(CommandMap commandMap)
 {
     commandMap.AssertAvailable(RedisCommand.LINDEX);
 }