BuildFeed/BuildFeed.Model/MongoConfig.cs
Thomas Hounsell 24e12c8741 Translation update - HU, TR; Fix #74
Also add auth support to the Mongo config provider. Leak date format
fix.
2016-10-03 23:06:40 +01:00

41 lines
1.2 KiB
C#

using System.Configuration;
namespace BuildFeed.Model
{
public static class MongoConfig
{
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 MongoConfig()
{
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"])
? ConfigurationManager.AppSettings["data:MongoHost"]
: "localhost";
int _port;
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
if (!success)
{
_port = 27017; // mongo default port
}
Port = _port;
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
? ConfigurationManager.AppSettings["data:MongoDB"]
: "MongoAuth";
Username = ConfigurationManager.AppSettings["data:MongoUser"] ?? "";
Password = ConfigurationManager.AppSettings["data:MongoPass"] ?? "";
}
public static void SetupIndexes()
{
BuildRepository b = new BuildRepository();
b.SetupIndexes();
}
}
}