using System;

namespace Dpz.Core.SourceGenerator.Attributes;

/// <summary>
/// 配置由源生成器生成的普通依赖注入注册。
/// </summary>
/// <remarks>
/// 该特性可标记在接口或实现类上,用于覆盖服务注册生命周期,
/// 或从约定注册中排除某个服务。
/// </remarks>
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class, Inherited = false)]
public sealed class DependencyInjectionAttribute(
    DependencyInjectionLifetime lifetime = DependencyInjectionLifetime.Scoped
) : Attribute
{
    /// <summary>
    /// 普通依赖注入注册的生命周期。
    /// </summary>
    public DependencyInjectionLifetime Lifetime { get; } = lifetime;

    /// <summary>
    /// 是否忽略该服务的自动注册。
    /// </summary>
    public bool Ignore { get; set; }
}
评论加载中...