-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExternalData.cs
More file actions
51 lines (46 loc) · 1.46 KB
/
ExternalData.cs
File metadata and controls
51 lines (46 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace AutomaticAnnouncements
{
static class ExternalData
{
// File contains sensitive data, therefore not on GitHub, though names should make everything obvius
// Functions here are to extract information from the file
private readonly static string path = "..\\..\\..\\config.json";
public static JToken GetSection(string section)
{
JObject json;
using (StreamReader r = new StreamReader(path))
{
json = JObject.Parse(r.ReadToEnd());
}
return json[section];
}
public static JToken GetSubSection(JToken section, string subSection)
{
return section[subSection];
}
public static EmailConfiguration GetEmailConfiguration()
{
JObject json;
using (StreamReader r = new StreamReader(path))
{
json = JObject.Parse(r.ReadToEnd());
}
EmailConfiguration config = new EmailConfiguration();
JToken section = json["EmailConfiguration"];
config.SmtpServer = (string)section["SmtpServer"];
config.SmtpPort = (int)section["SmtpPort"];
config.SmtpUsername = (string)section["SmtpUsername"];
config.SmtpPassword = (string)section["SmtpPassword"];
config.PopServer = (string)section["PopServer"];
config.PopPort = (int)section["PopPort"];
config.PopUsername = (string)section["PopUsername"];
config.PopPassword = (string)section["PopPassword"];
return config;
}
}
}