OptionsSettingsAttribute.cs
1.57 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
52
53
54
55
56
57
58
using NCC.Dependency;
using System;
namespace NCC.ConfigurableOptions
{
/// <summary>
/// 选项配置特性
/// </summary>
[SuppressSniffer, AttributeUsage(AttributeTargets.Class)]
public sealed class OptionsSettingsAttribute : Attribute
{
/// <summary>
/// 构造函数
/// </summary>
public OptionsSettingsAttribute()
{
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="path">appsetting.json 对应键</param>
public OptionsSettingsAttribute(string path)
{
Path = path;
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="postConfigureAll">启动所有实例进行后期配置</param>
public OptionsSettingsAttribute(bool postConfigureAll)
{
PostConfigureAll = postConfigureAll;
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="path">appsetting.json 对应键</param>
/// <param name="postConfigureAll">启动所有实例进行后期配置</param>
public OptionsSettingsAttribute(string path, bool postConfigureAll)
{
Path = path;
PostConfigureAll = postConfigureAll;
}
/// <summary>
/// 对应配置文件中的路径
/// </summary>
public string Path { get; set; }
/// <summary>
/// 对所有配置实例进行后期配置
/// </summary>
public bool PostConfigureAll { get; set; }
}
}