InjectionAttribute.cs
1.9 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
59
60
61
62
63
64
65
66
67
using System;
namespace NCC.Dependency
{
/// <summary>
/// 设置依赖注入方式
/// </summary>
[SuppressSniffer, AttributeUsage(AttributeTargets.Class)]
public class InjectionAttribute : Attribute
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="expectInterfaces"></param>
public InjectionAttribute(params Type[] expectInterfaces)
{
Action = InjectionActions.Add;
Pattern = InjectionPatterns.All;
ExpectInterfaces = expectInterfaces ?? Array.Empty<Type>();
Order = 0;
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="action"></param>
/// <param name="expectInterfaces"></param>
public InjectionAttribute(InjectionActions action, params Type[] expectInterfaces)
{
Action = action;
Pattern = InjectionPatterns.All;
ExpectInterfaces = expectInterfaces ?? Array.Empty<Type>();
Order = 0;
}
/// <summary>
/// 添加服务方式,存在不添加,或继续添加
/// </summary>
public InjectionActions Action { get; set; }
/// <summary>
/// 注册选项
/// </summary>
public InjectionPatterns Pattern { get; set; }
/// <summary>
/// 注册别名
/// </summary>
/// <remarks>多服务时使用</remarks>
public string Named { get; set; }
/// <summary>
/// 排序,排序越大,则在后面注册
/// </summary>
public int Order { get; set; }
/// <summary>
/// 排除接口
/// </summary>
public Type[] ExpectInterfaces { get; set; }
/// <summary>
/// 代理类型,必须继承 DispatchProxy、IDispatchProxy
/// </summary>
public Type Proxy { get; set; }
}
}