mirror of
https://github.com/jackqqq123/luban_ui_internal.git
synced 2025-12-17 21:38:22 +08:00
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
||
using System;
|
||
|
||
namespace LubanHub.Core.Attributes;
|
||
|
||
/// <summary>
|
||
/// 服务注册特性,用于标记需要自动注册到DI容器的服务
|
||
/// </summary>
|
||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||
public class RegistServiceAttribute : Attribute
|
||
{
|
||
/// <summary>
|
||
/// 服务生命周期
|
||
/// </summary>
|
||
public ServiceLifetime Lifetime { get; set; } = ServiceLifetime.Singleton;
|
||
|
||
/// <summary>
|
||
/// 服务接口类型,如果不指定则自动推断
|
||
/// </summary>
|
||
public Type? ServiceType { get; set; }
|
||
|
||
/// <summary>
|
||
/// 服务注册优先级,数值越小优先级越高
|
||
/// </summary>
|
||
public int Priority { get; set; } = 0;
|
||
|
||
/// <summary>
|
||
/// 初始化服务注册特性
|
||
/// </summary>
|
||
/// <param name="lifetime">服务生命周期</param>
|
||
/// <param name="serviceType">服务接口类型</param>
|
||
public RegistServiceAttribute(ServiceLifetime lifetime = ServiceLifetime.Singleton, Type? serviceType = null)
|
||
{
|
||
Lifetime = lifetime;
|
||
ServiceType = serviceType;
|
||
}
|
||
} |