Files
WCS/Cowain.Base/Attributes/AutoRegisterAttribute.cs
2026-03-02 09:08:20 +08:00

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;
}
}