-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.cs
More file actions
43 lines (35 loc) · 1.37 KB
/
Settings.cs
File metadata and controls
43 lines (35 loc) · 1.37 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
using System.Collections.Concurrent;
using System.Collections.Specialized;
using System.Configuration;
using System.IO;
namespace HTTPServer
{
class Settings
{
private const string fileKey = "file_";
private static int _port;
private static string _folder;
private static readonly ConcurrentDictionary<string, string> _files = new ConcurrentDictionary<string, string>();
public static void Initialization()
{
_port = int.Parse(ConfigurationManager.AppSettings["port"]);
_folder = ConfigurationManager.AppSettings["folder"];
if (!IsSite)
{
foreach (string key in ConfigurationManager.AppSettings)
{
if (key.StartsWith(fileKey))
{
string filePath = ConfigurationManager.AppSettings[key];
string fileName = Path.GetFileName(filePath);
_files.TryAdd(fileName, filePath);
}
}
}
}
public static int Port { get { return _port; } }
public static bool IsSite { get { return !string.IsNullOrEmpty(_folder); } }
public static string Folder { get { return _folder; } }
public static ConcurrentDictionary<string, string> Files { get { return _files; } }
}
}