-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.cs
51 lines (35 loc) · 1.2 KB
/
Settings.cs
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 System.Text.Json;
namespace WBImport
{
public sealed class MSSettings
{
#region Properties
public string AccessToken { get; set; }
public string SalesChannelId { get; set; }
#endregion Properties
}
public sealed class Settings
{
public static Settings Default { internal set; get; }
#region Properties
public MSSettings MoySklad { get; set; }
public WBSettings Wildberries { get; set; }
#endregion Properties
#region Methods
public static async Task<Settings> FromFileAsync(string fileName)
{
ArgumentNullException.ThrowIfNullOrEmpty(fileName, nameof(fileName));
if (!File.Exists(fileName))
throw new InvalidOperationException($"Файл настроек для пути \"{fileName}\" не найден.");
using var fileStream = File.OpenRead(fileName);
return await JsonSerializer.DeserializeAsync<Settings>(fileStream);
}
#endregion Methods
}
public sealed class WBSettings
{
#region Properties
public string AccessToken { get; set; }
#endregion Properties
}
}