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.
|
|
using Apewer.Internals; using System; using System.Collections.Generic; using System.Reflection; using System.Text;
namespace Apewer {
/// <summary></summary>
[Serializable] [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)] public class CaptionAttribute : Attribute {
private string _title, _description, _remark;
/// <summary></summary>
public CaptionAttribute(string title = null, string description = null, string remark = null) { Title = title; Description = description; Remark = remark; }
/// <summary></summary>
public string Title { get { return _title; } set { _title = value ?? Constant.EmptyString; } }
/// <summary></summary>
public string Description { get { return _description; } set { _description = value ?? Constant.EmptyString; } }
/// <summary></summary>
public string Remark { get { return _remark; } set { _remark = value ?? Constant.EmptyString; } }
/// <summary></summary>
public static string GetTitle(MethodInfo method, bool inherit = true) { if (method == null) return null;
var attributes = method.GetCustomAttributes(typeof(CaptionAttribute), inherit); if (attributes.Length > 0) { var attribute = attributes[0] as CaptionAttribute; return attribute.Title; }
return method.Name; }
}
}
|