Admin.Core/src/platform/ZhonTai.DynamicApi/Attributes/DynamicApiAttribute.cs

(完整代码) 1KB

using System;
using System.Reflection;
using ZhonTai.DynamicApi.Helpers;

namespace ZhonTai.DynamicApi.Attributes;

[Serializable]
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class)]
public class DynamicApiAttribute : Attribute
{
    /// <summary>
    /// Equivalent to AreaName
    /// </summary>
    public string Area { get; set; }

    /// <summary>
    /// 分组名称列表
    /// </summary>
    public string[] GroupNames { get; set; }

    internal static bool IsExplicitlyEnabledFor(Type type)
    {
        var remoteServiceAttr = type.GetTypeInfo().GetSingleAttributeOrNull<DynamicApiAttribute>();
        return remoteServiceAttr != null;
    }

    internal static bool IsExplicitlyDisabledFor(Type type)
    {
        var remoteServiceAttr = type.GetTypeInfo().GetSingleAttributeOrNull<DynamicApiAttribute>();
        return remoteServiceAttr != null;
    }

    internal static bool IsMetadataExplicitlyEnabledFor(Type type)
    {
        var remoteServiceAttr = type.GetTypeInfo().GetSingleAttributeOrNull<DynamicApiAttribute>();
        return remoteServiceAttr != null;
    }

    internal static bool IsMetadataExplicitlyDisabledFor(Type type)
    {
        var remoteServiceAttr = type.GetTypeInfo().GetSingleAttributeOrNull<DynamicApiAttribute>();
        return remoteServiceAttr != null;
    }

    internal static bool IsMetadataExplicitlyDisabledFor(MethodInfo method)
    {
        var remoteServiceAttr = method.GetSingleAttributeOrNull<DynamicApiAttribute>();
        return remoteServiceAttr != null;
    }

    internal static bool IsMetadataExplicitlyEnabledFor(MethodInfo method)
    {
        var remoteServiceAttr = method.GetSingleAttributeOrNull<DynamicApiAttribute>();
        return remoteServiceAttr != null;
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。