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

4 years ago
3 years ago
4 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Apewer
  4. {
  5. /// <summary>声明当前控制器类型可被 ApiEntries 获取。</summary>
  6. [Serializable]
  7. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
  8. public sealed class ApiAttribute : Attribute
  9. {
  10. string _name, _caption, _description;
  11. /// <summary>在枚举 Application 列表时,显示的名称。</summary>
  12. public string Name { get { return _name; } }
  13. /// <summary>在枚举 Application 列表时,显示的标题。</summary>
  14. public string Caption { get { return _caption; } }
  15. /// <summary>在枚举 Application 列表时,显示的说明。</summary>
  16. public string Description { get { return _description; } }
  17. /// <summary>创建 API 特性。</summary>
  18. public ApiAttribute(string name = null, string caption = null, string description = null)
  19. {
  20. _name = string.IsNullOrEmpty(name) ? null : name.Trim();
  21. _caption = string.IsNullOrEmpty(caption) ? null : caption.Trim();
  22. _description = string.IsNullOrEmpty(description) ? null : description.Trim();
  23. }
  24. /// <summary>从 <see cref="ApiAttribute"/> 到 Boolean 的隐式转换,判断 <see cref="ApiAttribute"/> 有效。</summary>
  25. public static implicit operator bool(ApiAttribute instance) => instance != null;
  26. }
  27. }