BuildFeed/BuildFeed.Model/MongoConfig.cs

36 lines
1014 B
C#
Raw Normal View History

2016-08-19 20:45:52 +08:00
using System.Configuration;
2015-08-05 19:28:16 +08:00
namespace BuildFeed.Model
2015-08-05 19:28:16 +08:00
{
public static class MongoConfig
2015-09-13 06:56:15 +08:00
{
2015-11-09 22:13:36 +08:00
public static string Host { get; }
public static int Port { get; }
public static string Database { get; }
2015-08-05 19:28:16 +08:00
2015-09-13 06:56:15 +08:00
static MongoConfig()
{
2016-08-19 20:45:52 +08:00
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"])
? ConfigurationManager.AppSettings["data:MongoHost"]
: "localhost";
2015-08-05 19:28:16 +08:00
2015-09-13 06:56:15 +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 19:28:16 +08:00
2016-08-19 20:45:52 +08:00
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
? ConfigurationManager.AppSettings["data:MongoDB"]
: "MongoAuth";
2015-09-13 06:56:15 +08:00
}
public static void SetupIndexes()
{
BuildRepository b = new BuildRepository();
b.SetupIndexes();
}
2015-09-13 06:56:15 +08:00
}
2015-08-05 19:28:16 +08:00
}