2015-08-05 04:07:31 +08:00
|
|
|
|
using System.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace MongoAuth
|
|
|
|
|
{
|
2015-11-09 22:13:36 +08:00
|
|
|
|
internal static class DatabaseConfig
|
|
|
|
|
{
|
|
|
|
|
public static string Host { get; }
|
|
|
|
|
public static int Port { get; }
|
|
|
|
|
public static string Database { get; }
|
2015-08-05 04:07:31 +08:00
|
|
|
|
|
2015-11-09 22:13:36 +08:00
|
|
|
|
static DatabaseConfig()
|
|
|
|
|
{
|
|
|
|
|
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"]) ?
|
|
|
|
|
ConfigurationManager.AppSettings["data:MongoHost"] :
|
|
|
|
|
"localhost";
|
2015-08-05 04:07:31 +08:00
|
|
|
|
|
2015-11-09 22:13:36 +08:00
|
|
|
|
int _port;
|
|
|
|
|
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
|
|
|
|
|
if (!success)
|
|
|
|
|
{
|
|
|
|
|
_port = 27017; // mongo default port
|
|
|
|
|
}
|
|
|
|
|
Port = _port;
|
2015-08-05 04:07:31 +08:00
|
|
|
|
|
2015-11-09 22:13:36 +08:00
|
|
|
|
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"]) ?
|
|
|
|
|
ConfigurationManager.AppSettings["data:MongoDB"] :
|
|
|
|
|
"MongoAuth";
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-05 04:07:31 +08:00
|
|
|
|
}
|