public class UseDIAttribute : Attribute[UseDI(ServiceLifetime.Transient)]
public class MyService : xxx { }
[UseDI(typeof(xxx), typeof(yyy))]
public class MyService : xxx { }
[UseDI(ServiceLifetime.Transient, typeof(xxx))]
public class MyService : xxx { }
// Keyed Service
[UseDI("someKey", ServiceLifetime.Singleton, typeof(xxx))]
public class MyService : xxx { }| UseDIAttribute(object) | 使用指定的服务 Key 初始化实例,生命周期将为 Singleton。 |
| UseDIAttribute(Type) | 使用指定的服务类型初始化实例,生命周期将为 Singleton。 |
| UseDIAttribute(ServiceLifetime, Type) | 使用指定的生命周期以及指定的服务类型初始化实例。 |
| UseDIAttribute(object, ServiceLifetime, Type) | 使用指定的服务 Key、生命周期以及指定的服务类型初始化实例。 |
Public Properties | |
| Lifetime | 获取要注册的服务的生命周期。 |
| ServiceKey | 获取要注册的服务的 Key。 |
| ServiceTypes | 获取要注册的服务类型数组。 |