2015-06-05 17:03:36 +08:00
|
|
|
|
using System.Configuration;
|
2014-10-11 06:57:02 +08:00
|
|
|
|
|
2015-06-05 17:03:36 +08:00
|
|
|
|
namespace RedisAuth
|
2014-10-11 06:57:02 +08:00
|
|
|
|
{
|
2015-06-05 17:03:36 +08:00
|
|
|
|
internal static class DatabaseConfig
|
2014-10-11 06:57:02 +08:00
|
|
|
|
{
|
|
|
|
|
public static string Host { get; private set; }
|
|
|
|
|
public static int Port { get; private set; }
|
|
|
|
|
public static long Database { get; private set; }
|
|
|
|
|
|
|
|
|
|
static DatabaseConfig()
|
|
|
|
|
{
|
|
|
|
|
Host = ConfigurationManager.AppSettings["data:ServerHost"];
|
|
|
|
|
|
|
|
|
|
int _port;
|
|
|
|
|
bool success = int.TryParse(ConfigurationManager.AppSettings["data:ServerPort"], out _port);
|
2015-06-05 17:03:36 +08:00
|
|
|
|
if (!success)
|
2014-10-11 06:57:02 +08:00
|
|
|
|
{
|
|
|
|
|
_port = 6379; // redis default port
|
|
|
|
|
}
|
|
|
|
|
Port = _port;
|
|
|
|
|
|
|
|
|
|
long _db;
|
|
|
|
|
success = long.TryParse(ConfigurationManager.AppSettings["data:ServerDB"], out _db);
|
|
|
|
|
if (!success)
|
|
|
|
|
{
|
|
|
|
|
_db = 0; // redis default db
|
|
|
|
|
}
|
|
|
|
|
Database = _db;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|