You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace DS.Module.Core.Attributes;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 配置此特性将自动进行注入
|
|
|
|
|
/// </summary>
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
|
|
|
public class DependencyAttribute : Attribute
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造函数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="lifetime">注入类型(Scoped\Singleton\Transient)</param>
|
|
|
|
|
public DependencyAttribute(ServiceLifetime lifetime)
|
|
|
|
|
{
|
|
|
|
|
Lifetime = lifetime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ServiceLifetime Lifetime { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取或设置 是否注册自身类型,默认没有接口的类型会注册自身,当此属性值为true时,也会注册自身
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool AddSelf { get; set; }
|
|
|
|
|
}
|