2015-08-05 04:07:31 +08:00
|
|
|
|
using System.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace MongoAuth
|
|
|
|
|
{
|
2017-04-12 22:04:23 +08:00
|
|
|
|
internal static class DatabaseConfig
|
|
|
|
|
{
|
|
|
|
|
public static string Host { get; }
|
|
|
|
|
public static int Port { get; }
|
|
|
|
|
public static string Database { get; }
|
|
|
|
|
public static string Username { get; }
|
|
|
|
|
public static string Password { get; }
|
2015-08-05 04:07:31 +08:00
|
|
|
|
|
2017-04-12 22:04:23 +08:00
|
|
|
|
static DatabaseConfig()
|
|
|
|
|
{
|
|
|
|
|
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"])
|
|
|
|
|
? ConfigurationManager.AppSettings["data:MongoHost"]
|
|
|
|
|
: "localhost";
|
2015-08-05 04:07:31 +08:00
|
|
|
|
|
2017-04-17 18:11:45 +08:00
|
|
|
|
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out int port);
|
2017-04-12 22:04:23 +08:00
|
|
|
|
if (!success)
|
|
|
|
|
{
|
|
|
|
|
port = 27017; // mongo default port
|
|
|
|
|
}
|
2018-02-07 06:16:37 +08:00
|
|
|
|
|
2017-04-12 22:04:23 +08:00
|
|
|
|
Port = port;
|
2015-08-05 04:07:31 +08:00
|
|
|
|
|
2017-04-12 22:04:23 +08:00
|
|
|
|
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
|
|
|
|
|
? ConfigurationManager.AppSettings["data:MongoDB"]
|
|
|
|
|
: "MongoAuth";
|
2016-10-04 06:06:40 +08:00
|
|
|
|
|
2017-04-12 22:04:23 +08:00
|
|
|
|
Username = ConfigurationManager.AppSettings["data:MongoUser"] ?? "";
|
|
|
|
|
Password = ConfigurationManager.AppSettings["data:MongoPass"] ?? "";
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-05 04:07:31 +08:00
|
|
|
|
}
|