Пример #1
0
        private ProviderConfiguration(NameValueCollection config)
        {
            EnableLoggingIfParametersAvailable(config);
            // Get connection host, port and password.
            // host, port, accessKey and ssl are firest fetched from appSettings if not found there than taken from web.config
            ConnectionString    = GetConnectionString(config);
            Host                = GetStringSettings(config, "host", "127.0.0.1");
            Port                = GetIntSettings(config, "port", 0);
            AccessKey           = GetStringSettings(config, "accessKey", null);
            UseSsl              = GetBoolSettings(config, "ssl", true);
            RedisSerializerType = GetStringSettings(config, "redisSerializerType", null);
            ConnectionMultiplexerFactoryType = GetStringSettings(config, "connectionMultiplexerFactoryType", null);
            // All below parameters are only fetched from web.config
            DatabaseId      = GetIntSettings(config, "databaseId", 0);
            ApplicationName = GetStringSettings(config, "applicationName", null);
            if (ApplicationName == null)
            {
                try
                {
                    ApplicationName = HostingEnvironment.ApplicationVirtualPath;
                    if (String.IsNullOrEmpty(ApplicationName))
                    {
                        ApplicationName = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;

                        int indexOfDot = ApplicationName.IndexOf('.');
                        if (indexOfDot != -1)
                        {
                            ApplicationName = ApplicationName.Remove(indexOfDot);
                        }
                    }

                    if (String.IsNullOrEmpty(ApplicationName))
                    {
                        ApplicationName = "/";
                    }
                }
                catch (Exception e)
                {
                    ApplicationName = "/";
                    LogUtility.LogInfo(e.Message);
                }
            }

            ConnectionTimeoutInMilliSec = GetIntSettings(config, "connectionTimeoutInMilliseconds", 0);
            OperationTimeoutInMilliSec  = GetIntSettings(config, "operationTimeoutInMilliseconds", 0);
        }