Files
luban_ui_internal/src/LubanHub.Core/Attributes/RegistServiceAttribute.cs
jackqqq123 369fcbf403 feat: Luban.Core初步实现,提供能力:
- RegistService 装饰器实现服务注册
- 下载服务
- 文件服务
- 多线程方法
- 解压缩服务
2025-09-24 12:07:03 +08:00

37 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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