using Microsoft.Extensions.DependencyInjection;
using System;
namespace LubanHub.Core.Attributes;
///
/// 服务注册特性,用于标记需要自动注册到DI容器的服务
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class RegistServiceAttribute : Attribute
{
///
/// 服务生命周期
///
public ServiceLifetime Lifetime { get; set; } = ServiceLifetime.Singleton;
///
/// 服务接口类型,如果不指定则自动推断
///
public Type? ServiceType { get; set; }
///
/// 服务注册优先级,数值越小优先级越高
///
public int Priority { get; set; } = 0;
///
/// 初始化服务注册特性
///
/// 服务生命周期
/// 服务接口类型
public RegistServiceAttribute(ServiceLifetime lifetime = ServiceLifetime.Singleton, Type? serviceType = null)
{
Lifetime = lifetime;
ServiceType = serviceType;
}
}