19 lines
464 B
C#
19 lines
464 B
C#
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Cowain.Base.Attributes;
|
|
|
|
|
|
/// <summary>
|
|
/// 服务注册特性 - 支持自定义生命周期
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public class AutoRegisterAttribute : Attribute
|
|
{
|
|
public ServiceLifetime Lifetime { get; set; } = ServiceLifetime.Scoped;
|
|
public AutoRegisterAttribute(ServiceLifetime lifetime = ServiceLifetime.Scoped)
|
|
{
|
|
Lifetime = lifetime;
|
|
}
|
|
}
|