mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
36 lines
1014 B
C#
36 lines
1014 B
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; }
|
|
|
|
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";
|
|
}
|
|
|
|
public static void SetupIndexes()
|
|
{
|
|
BuildRepository b = new BuildRepository();
|
|
b.SetupIndexes();
|
|
}
|
|
}
|
|
} |