BuildFeed/Authentication/MongoAuth/DatabaseConfig.cs

35 lines
1.1 KiB
C#
Raw Normal View History

using System.Configuration;
namespace MongoAuth
{
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; }
static DatabaseConfig()
{
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"])
? ConfigurationManager.AppSettings["data:MongoHost"]
: "localhost";
2017-04-17 18:11:45 +08:00
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out int port);
if (!success)
{
port = 27017; // mongo default port
}
2018-02-07 06:16:37 +08:00
Port = port;
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
? ConfigurationManager.AppSettings["data:MongoDB"]
: "MongoAuth";
Username = ConfigurationManager.AppSettings["data:MongoUser"] ?? "";
Password = ConfigurationManager.AppSettings["data:MongoPass"] ?? "";
}
}
}