EasyConfigOptionAttribute.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace EasyDevCore.Configuration
  7. {
  8. /// <summary>
  9. ///
  10. /// </summary>
  11. [Flags]
  12. public enum EasyConfigPropertyOptions
  13. {
  14. /// <summary>
  15. ///
  16. /// </summary>
  17. None = 0,
  18. /// <summary>
  19. /// It will be save in Binary Serialization
  20. /// </summary>
  21. Serialization = 1,
  22. /// <summary>
  23. /// It has been encrypted
  24. /// </summary>
  25. Encrypted = 2,
  26. /// <summary>
  27. /// Internal property / Not save in file
  28. /// </summary>
  29. Internal = 4
  30. }
  31. /// <summary>
  32. ///
  33. /// </summary>
  34. /// <seealso cref="System.Attribute" />
  35. public class EasyConfigPropertyAttribute: Attribute
  36. {
  37. /// <summary>
  38. /// Gets or sets the default value.
  39. /// </summary>
  40. /// <value>The default value.</value>
  41. public object DefaultValue { get; set; }
  42. /// <summary>
  43. /// Gets or sets the min value.
  44. /// </summary>
  45. /// <value>
  46. /// The min value.
  47. /// </value>
  48. public object MinValue { get; set; }
  49. /// <summary>
  50. /// Gets or sets the max value.
  51. /// </summary>
  52. /// <value>
  53. /// The max value.
  54. /// </value>
  55. public object MaxValue { get; set; }
  56. /// <summary>
  57. /// Gets or sets the tag.
  58. /// </summary>
  59. /// <value>
  60. /// The tag.
  61. /// </value>
  62. public string Tag { get; set; }
  63. /// <summary>
  64. /// Gets or sets a value indicating whether this instance is encrypted.
  65. /// </summary>
  66. /// <value>
  67. /// <c>true</c> if this instance is encrypted; otherwise, <c>false</c>.
  68. /// </value>
  69. public bool IsEncrypted
  70. {
  71. get
  72. {
  73. return ((Options & EasyConfigPropertyOptions.Encrypted) != EasyConfigPropertyOptions.None);
  74. }
  75. set
  76. {
  77. if (value)
  78. {
  79. Options |= EasyConfigPropertyOptions.Encrypted;
  80. }
  81. else
  82. {
  83. Options &= ~EasyConfigPropertyOptions.Encrypted;
  84. }
  85. }
  86. }
  87. /// <summary>
  88. /// Gets or sets a value indicating whether this instance is internal.
  89. /// </summary>
  90. /// <value>
  91. /// <c>true</c> if this instance is internal; otherwise, <c>false</c>.
  92. /// </value>
  93. public bool IsInternal
  94. {
  95. get
  96. {
  97. return ((Options & EasyConfigPropertyOptions.Internal) != EasyConfigPropertyOptions.None);
  98. }
  99. set
  100. {
  101. if (value)
  102. {
  103. Options |= EasyConfigPropertyOptions.Internal;
  104. }
  105. else
  106. {
  107. Options &= ~EasyConfigPropertyOptions.Internal;
  108. }
  109. }
  110. }
  111. /// <summary>
  112. /// Gets or sets a value indicating whether this instance is serialization.
  113. /// </summary>
  114. /// <value>
  115. /// <c>true</c> if this instance is serialization; otherwise, <c>false</c>.
  116. /// </value>
  117. public bool IsSerialization
  118. {
  119. get
  120. {
  121. return ((Options & EasyConfigPropertyOptions.Serialization) != EasyConfigPropertyOptions.None);
  122. }
  123. set
  124. {
  125. if (value)
  126. {
  127. Options |= EasyConfigPropertyOptions.Serialization;
  128. }
  129. else
  130. {
  131. Options &= ~EasyConfigPropertyOptions.Serialization;
  132. }
  133. }
  134. }
  135. /// <summary>
  136. /// Gets or sets the alias.
  137. /// </summary>
  138. /// <value>
  139. /// The alias.
  140. /// </value>
  141. public string Alias { get; set; }
  142. /// <summary>
  143. /// Gets or sets the options.
  144. /// </summary>
  145. /// <value>The options.</value>
  146. public EasyConfigPropertyOptions Options { get; set; }
  147. }
  148. }