FieldAttribute.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. namespace Core.StlMes.Client.Qcm
  3. {
  4. public enum FieldAttributeType
  5. {
  6. QueryField = 1, //如果不填,则二进制只有一位。就无法正常使用枚举的异或、与运算了。
  7. NoQueryField = 2
  8. }
  9. /// <summary>
  10. /// 用来标识实体类的属性,以被转换器使用。
  11. /// </summary>
  12. [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
  13. class FieldAttribute : Attribute
  14. {
  15. private string _fieldName = "";
  16. private bool _isGetValue = false;
  17. private FieldAttributeType _fieldAttributeType;
  18. /// <summary>
  19. /// 字段名称
  20. /// </summary>
  21. public string FieldName
  22. {
  23. get { return _fieldName; }
  24. set { _fieldName = value; }
  25. }
  26. /// <summary>
  27. /// 是取Value的值还是取Text的值
  28. /// </summary>
  29. public bool IsGetValue
  30. {
  31. get { return _isGetValue; }
  32. set { _isGetValue = value; }
  33. }
  34. /// <summary>
  35. /// 字段类型(用于查询条件还是新增修改或者保存条件)
  36. /// </summary>
  37. public FieldAttributeType FieldAttributeType
  38. {
  39. get { return _fieldAttributeType; }
  40. set { _fieldAttributeType = value; }
  41. }
  42. /// <summary>
  43. /// 字段特性构造函数(默认为实体类的属性名称)
  44. /// </summary>
  45. /// <param name="isGetValue">是取Value的值还是取Text的值</param>
  46. ///<param name="fieldAttributeType">字段类型(用于查询条件还是新增修改或者保存条件)</param>
  47. public FieldAttribute(bool isGetValue, FieldAttributeType fieldAttributeType)
  48. {
  49. _isGetValue = isGetValue;
  50. _fieldAttributeType = fieldAttributeType;
  51. }
  52. /// <summary>
  53. /// 字段特性构造函数
  54. /// </summary>
  55. /// <param name="fieldName">字段名称</param>
  56. /// <param name="isGetValue">是取Value的值还是取Text的值</param>
  57. ///<param name="fieldAttributeType">字段类型(用于查询条件还是新增修改或者保存条件)</param>
  58. public FieldAttribute(string fieldName, bool isGetValue, FieldAttributeType fieldAttributeType)
  59. {
  60. _fieldName = fieldName;
  61. _isGetValue = isGetValue;
  62. _fieldAttributeType = fieldAttributeType;
  63. }
  64. }
  65. }