123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CP.Common
- {
- public static class AttributeHelper
- {
- /// <summary>
- /// 获取彩种对应编码
- /// </summary>
- /// <param name="value">彩种枚举类型</param>
- /// <returns></returns>
- public static string GetAttributeText(Enum value)
- {
- if (value == null)
- {
- throw new ArgumentException("value");
- }
- string code = value.ToString();
- var fieldInfo = value.GetType().GetField(code);
- return ((TextAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(TextAttribute))).Text;
- }
- }
- /// <summary>
- /// 父节点
- /// </summary>
- public class ParentAttribute : Attribute
- {
- private int parent;
- public ParentAttribute(int value)
- {
- parent = value;
- }
- public int Parent
- {
- get
- {
- return parent;
- }
- }
- }
- public class ImgAttribute : Attribute
- {
- private string img;
- public ImgAttribute(string value)
- {
- img = value;
- }
- public string Img
- {
- get
- {
- return img;
- }
- }
- }
- public class TextAttribute : Attribute
- {
- private string text;
- public TextAttribute(string value)
- {
- this.text = value;
- }
- public string Text
- {
- get
- {
- return text;
- }
- }
- }
- }
|