You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

using System;
using System.Collections.Generic;
namespace Apewer
{
/// <summary>声明当前控制器类型可被 ApiEntries 获取。</summary>
[Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public sealed class ApiAttribute : Attribute
{
string _name, _caption, _description;
/// <summary>在枚举 Application 列表时,显示的名称。</summary>
public string Name { get { return _name; } }
/// <summary>在枚举 Application 列表时,显示的标题。</summary>
public string Caption { get { return _caption; } }
/// <summary>在枚举 Application 列表时,显示的说明。</summary>
public string Description { get { return _description; } }
/// <summary>创建 API 特性。</summary>
public ApiAttribute(string name = null, string caption = null, string description = null)
{
_name = string.IsNullOrEmpty(name) ? null : name.Trim();
_caption = string.IsNullOrEmpty(caption) ? null : caption.Trim();
_description = string.IsNullOrEmpty(description) ? null : description.Trim();
}
/// <summary>从 <see cref="ApiAttribute"/> 到 Boolean 的隐式转换,判断 <see cref="ApiAttribute"/> 有效。</summary>
public static implicit operator bool(ApiAttribute instance) => instance != null;
}
}