sockscape/server_old/Configuration.cs

77 lines
2.2 KiB
C#
Raw Normal View History

2017-06-07 21:02:29 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2017-07-22 19:27:41 +00:00
using Glove.INI;
2017-06-07 21:02:29 +00:00
2017-07-22 19:27:41 +00:00
namespace SockScape {
2017-06-07 21:02:29 +00:00
public static class Configuration {
2017-08-21 21:03:32 +00:00
private static readonly SettingsFile Settings;
2017-06-07 21:02:29 +00:00
static Configuration() {
Settings = new SettingsFile(
"config.ini",
new List<SectionRules> {
new SectionRules {
Name = "General",
Required = true,
2017-08-21 21:03:32 +00:00
RequiredFields = new[] {
2017-06-07 21:02:29 +00:00
"Run Master",
"Master Port",
"Master Addr",
2017-08-30 21:02:51 +00:00
"Master Secret",
"Master IV",
2017-06-07 21:02:29 +00:00
"Max Users"
}
},
new SectionRules {
Name = "Mail",
Required = true,
RequiredFields = new[] {
"Host",
"UseTLS",
"Auth"
}
},
new SectionRules {
Name = "Database",
Required = true,
2017-08-21 21:03:32 +00:00
RequiredFields = new[] {
"Server",
"Username",
"Password",
"Database"
}
},
2017-06-07 21:02:29 +00:00
new SectionRules {
Name = "Server",
AllowMultiple = true,
Required = true,
2017-08-21 21:03:32 +00:00
RequiredFields = new[] {
2017-06-07 21:02:29 +00:00
"Id",
"Port"
}
}
}
);
}
public static Section Get(string section) {
return Settings[section];
}
2017-08-21 21:03:32 +00:00
public static Instance General
=> Settings["General"][0];
2017-06-07 21:02:29 +00:00
2017-08-21 21:03:32 +00:00
public static Instance Database
=> Settings["Database"][0];
2017-08-21 21:03:32 +00:00
public static Section Servers
=> Settings["Server"];
2017-06-07 21:02:29 +00:00
}
}