Attributes.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace DymWebForm.Aspx
  6. {
  7. //meta
  8. [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
  9. public sealed class DWFMetaAttribute : Attribute
  10. {
  11. public Type Type { get; private set; }
  12. public DWFMetaAttribute(Type type)
  13. {
  14. Type = type;
  15. }
  16. }
  17. //db
  18. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  19. public sealed class DWFIgnoreAttribute : Attribute
  20. {
  21. }
  22. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  23. public sealed class DWFPKAttribute : Attribute
  24. {
  25. }
  26. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  27. public sealed class DWFAllowNullAttribute : Attribute
  28. {
  29. }
  30. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  31. public sealed class DWFFKDisplayAttribute : Attribute
  32. {
  33. }
  34. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  35. public sealed class DWFFKAttribute : Attribute
  36. {
  37. public Type ParentType
  38. {
  39. get;
  40. private set;
  41. }
  42. public DWFFKAttribute(Type parentType)
  43. {
  44. this.ParentType = parentType;
  45. }
  46. }
  47. //form uis
  48. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  49. public sealed class DWFDisplayOrderAttribute : Attribute
  50. {
  51. public int DisplayOrder
  52. {
  53. get;
  54. private set;
  55. }
  56. public DWFDisplayOrderAttribute(int displayOrder)
  57. {
  58. this.DisplayOrder = displayOrder;
  59. }
  60. }
  61. //defalut values
  62. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  63. public abstract class DWFDefaultValueGeneratorAttribute : Attribute
  64. {
  65. public abstract object GenerateValue();
  66. }
  67. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  68. public class DWFDefaultValueDateTimeNowAttribute : DWFDefaultValueGeneratorAttribute
  69. {
  70. public override object GenerateValue()
  71. {
  72. return DateTime.Now;
  73. }
  74. }
  75. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  76. public class DWFDefaultValueBoolAttribute : DWFDefaultValueGeneratorAttribute
  77. {
  78. private bool m_value;
  79. public override object GenerateValue()
  80. {
  81. return m_value;
  82. }
  83. public DWFDefaultValueBoolAttribute(bool value)
  84. {
  85. m_value = value;
  86. }
  87. }
  88. //validations
  89. [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
  90. public class DWFValidationTypeAttribute : Attribute
  91. {
  92. internal Type ValidationType { get; private set; }
  93. public DWFValidationTypeAttribute(Type validationType)
  94. {
  95. ValidationType = validationType;
  96. }
  97. }
  98. }