Files
Yi.Admin/Yi.Framework.Net6/Yi.Framework.Common/Attribute/AppServiceAttribute.cs

31 lines
930 B
C#
Raw Normal View History

2022-10-09 17:32:44 +08:00

using System;
namespace Yi.Framework.Common.Attribute
{
/// <summary>
/// 参考地址https://www.cnblogs.com/kelelipeng/p/10643556.html
/// 1、[AppService]:自动去找接口,如果存在就是接口,如果不存在就是本身
/// 2、[AppService(ServiceType = typeof(注册抽象或者接口或者本身))]手动去注册放type即可
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class AppServiceAttribute : System.Attribute
{
/// <summary>
/// 服务声明周期
/// 不给默认值的话注册的是作用域
/// </summary>
public LifeTime ServiceLifetime { get; set; } = LifeTime.Scoped;
/// <summary>
/// 指定服务类型
/// </summary>
public Type ServiceType { get; set; }
}
public enum LifeTime
{
Transient, Scoped, Singleton
}
}