2015-08-04 21:07:31 +01:00
|
|
|
|
using System.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace MongoAuth
|
|
|
|
|
{
|
2015-11-09 14:13:36 +00:00
|
|
|
|
internal static class DatabaseConfig
|
|
|
|
|
{
|
|
|
|
|
public static string Host { get; }
|
|
|
|
|
public static int Port { get; }
|
|
|
|
|
public static string Database { get; }
|
2016-10-03 23:06:40 +01:00
|
|
|
|
public static string Username { get; }
|
|
|
|
|
public static string Password { get; }
|
2015-08-04 21:07:31 +01:00
|
|
|
|
|
2015-11-09 14:13:36 +00:00
|
|
|
|
static DatabaseConfig()
|
|
|
|
|
{
|
2016-08-19 13:45:52 +01:00
|
|
|
|
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"])
|
|
|
|
|
? ConfigurationManager.AppSettings["data:MongoHost"]
|
|
|
|
|
: "localhost";
|
2015-08-04 21:07:31 +01:00
|
|
|
|
|
2015-11-09 14:13:36 +00:00
|
|
|
|
int _port;
|
|
|
|
|
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
|
|
|
|
|
if (!success)
|
|
|
|
|
{
|
|
|
|
|
_port = 27017; // mongo default port
|
|
|
|
|
}
|
|
|
|
|
Port = _port;
|
2015-08-04 21:07:31 +01:00
|
|
|
|
|
2016-08-19 13:45:52 +01:00
|
|
|
|
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
|
|
|
|
|
? ConfigurationManager.AppSettings["data:MongoDB"]
|
|
|
|
|
: "MongoAuth";
|
2016-10-03 23:06:40 +01:00
|
|
|
|
|
|
|
|
|
Username = ConfigurationManager.AppSettings["data:MongoUser"] ?? "";
|
|
|
|
|
Password = ConfigurationManager.AppSettings["data:MongoPass"] ?? "";
|
2015-11-09 14:13:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-04 21:07:31 +01:00
|
|
|
|
}
|