1
+ // ***********************************************************************
2
+ // Assembly : RzR.Shared.Export.DynamicExcelProvider
3
+ // Author : RzR
4
+ // Created On : 2024-10-03 19:03
5
+ //
6
+ // Last Modified By : RzR
7
+ // Last Modified On : 2024-10-04 19:02
8
+ // ***********************************************************************
9
+ // <copyright file="ExcelPropValidationAttribute.cs" company="">
10
+ // Copyright (c) RzR. All rights reserved.
11
+ // </copyright>
12
+ //
13
+ // <summary>
14
+ // </summary>
15
+ // ***********************************************************************
16
+
17
+ #region U S A G E S
18
+
19
+ using DynamicExcelProvider . Enums ;
20
+ using System ;
21
+ using System . Collections . Generic ;
22
+
23
+ #endregion
24
+
25
+ namespace DynamicExcelProvider . Attributes
26
+ {
27
+ /// -------------------------------------------------------------------------------------------------
28
+ /// <summary>
29
+ /// Attribute for excel property validation.
30
+ /// </summary>
31
+ /// <seealso cref="T:Attribute"/>
32
+ /// =================================================================================================
33
+ [ AttributeUsage ( AttributeTargets . Property ) ]
34
+ public class ExcelPropValidationAttribute : Attribute
35
+ {
36
+ /// <inheritdoc/>
37
+ public ExcelPropValidationAttribute (
38
+ ValidationType validationType ,
39
+ ValidationOperatorType operatorType ,
40
+ string [ ] allowedValues ,
41
+ object minValue ,
42
+ object maxValue ,
43
+ string errorMessage = null ,
44
+ string promptMessage = null ,
45
+ bool allowEmpty = true
46
+ /*bool showListInDropDown = true*/ )
47
+ {
48
+ ValidationType = validationType ;
49
+ OperatorType = operatorType ;
50
+ AllowedValues = allowedValues ;
51
+ MinValue = ( int ? ) minValue ;
52
+ MaxValue = ( int ? ) maxValue ;
53
+ ErrorMessage = errorMessage ;
54
+ PromptMessage = promptMessage ;
55
+ AllowEmpty = allowEmpty ;
56
+ //ShowListInDropDown = showListInDropDown;
57
+ ShowListInDropDown = false ;
58
+ }
59
+
60
+ /// <inheritdoc/>
61
+ public ExcelPropValidationAttribute (
62
+ ValidationType validationType ,
63
+ ValidationOperatorType operatorType ,
64
+ string [ ] allowedValues ,
65
+ string errorMessage = null ,
66
+ string promptMessage = null ,
67
+ bool allowEmpty = true
68
+ /*bool showListInDropDown = true*/ )
69
+ {
70
+ ValidationType = validationType ;
71
+ OperatorType = operatorType ;
72
+ AllowedValues = allowedValues ;
73
+ ErrorMessage = errorMessage ;
74
+ PromptMessage = promptMessage ;
75
+ AllowEmpty = allowEmpty ;
76
+ //ShowListInDropDown = showListInDropDown;
77
+ ShowListInDropDown = false ;
78
+ }
79
+
80
+ /// <inheritdoc/>
81
+ public ExcelPropValidationAttribute (
82
+ ValidationType validationType ,
83
+ ValidationOperatorType operatorType ,
84
+ object minValue ,
85
+ object maxValue ,
86
+ string errorMessage = null ,
87
+ string promptMessage = null ,
88
+ bool allowEmpty = true )
89
+ {
90
+ ValidationType = validationType ;
91
+ OperatorType = operatorType ;
92
+ MinValue = ( int ? ) minValue ;
93
+ MaxValue = ( int ? ) maxValue ;
94
+ ErrorMessage = errorMessage ;
95
+ PromptMessage = promptMessage ;
96
+ AllowEmpty = allowEmpty ;
97
+ }
98
+
99
+ /// <inheritdoc/>
100
+ public ExcelPropValidationAttribute (
101
+ ValidationType validationType ,
102
+ ValidationOperatorType operatorType ,
103
+ object minValue ,
104
+ string errorMessage = null ,
105
+ string promptMessage = null ,
106
+ bool allowEmpty = true )
107
+ {
108
+ ValidationType = validationType ;
109
+ OperatorType = operatorType ;
110
+ MinValue = ( int ? ) minValue ;
111
+ ErrorMessage = errorMessage ;
112
+ PromptMessage = promptMessage ;
113
+ AllowEmpty = allowEmpty ;
114
+ }
115
+
116
+ /// -------------------------------------------------------------------------------------------------
117
+ /// <summary>
118
+ /// Initializes a new instance of the <see cref="ExcelPropValidationAttribute"/> class.
119
+ /// </summary>
120
+ /// =================================================================================================
121
+ public ExcelPropValidationAttribute ( )
122
+ {
123
+ }
124
+
125
+ /// -------------------------------------------------------------------------------------------------
126
+ /// <summary>
127
+ /// Gets or sets the type of the validation.
128
+ /// </summary>
129
+ /// <value>
130
+ /// The type of the validation.
131
+ /// </value>
132
+ /// =================================================================================================
133
+ public ValidationType ValidationType { get ; set ; }
134
+
135
+ /// -------------------------------------------------------------------------------------------------
136
+ /// <summary>
137
+ /// Gets or sets the type of the operator.
138
+ /// </summary>
139
+ /// <value>
140
+ /// The type of the operator.
141
+ /// </value>
142
+ /// =================================================================================================
143
+ public ValidationOperatorType OperatorType { get ; set ; }
144
+
145
+ /// -------------------------------------------------------------------------------------------------
146
+ /// <summary>
147
+ /// Gets or sets the allowed values.
148
+ /// </summary>
149
+ /// <value>
150
+ /// The allowed values.
151
+ /// </value>
152
+ /// =================================================================================================
153
+ public IEnumerable < string > AllowedValues { get ; set ; }
154
+
155
+ /// -------------------------------------------------------------------------------------------------
156
+ /// <summary>
157
+ /// Gets or sets the minimum value (INT_32).
158
+ /// </summary>
159
+ /// <value>
160
+ /// The minimum value.
161
+ /// </value>
162
+ /// =================================================================================================
163
+ public object MinValue { get ; set ; }
164
+
165
+ /// -------------------------------------------------------------------------------------------------
166
+ /// <summary>
167
+ /// Gets or sets the maximum value (INT_32).
168
+ /// </summary>
169
+ /// <value>
170
+ /// The maximum value.
171
+ /// </value>
172
+ /// =================================================================================================
173
+ public object MaxValue { get ; set ; }
174
+
175
+ /// -------------------------------------------------------------------------------------------------
176
+ /// <summary>
177
+ /// Gets or sets a message describing the error.
178
+ /// </summary>
179
+ /// <value>
180
+ /// A message describing the error.
181
+ /// </value>
182
+ /// =================================================================================================
183
+ public string ErrorMessage { get ; set ; }
184
+
185
+ /// -------------------------------------------------------------------------------------------------
186
+ /// <summary>
187
+ /// Gets or sets a message describing the prompt.
188
+ /// </summary>
189
+ /// <value>
190
+ /// A message describing the prompt.
191
+ /// </value>
192
+ /// =================================================================================================
193
+ public string PromptMessage { get ; set ; }
194
+
195
+ /// -------------------------------------------------------------------------------------------------
196
+ /// <summary>
197
+ /// Gets or sets a value indicating whether we allow empty.
198
+ /// </summary>
199
+ /// <value>
200
+ /// True if allow empty, false if not.
201
+ /// </value>
202
+ /// =================================================================================================
203
+ public bool AllowEmpty { get ; set ; }
204
+
205
+ /// -------------------------------------------------------------------------------------------------
206
+ /// <summary>
207
+ /// Gets or sets a value indicating whether the list in drop down is shown.
208
+ /// </summary>
209
+ /// <value>
210
+ /// True if show list in drop down, false if not.
211
+ /// </value>
212
+ /// =================================================================================================
213
+ internal bool ShowListInDropDown { get ; set ; }
214
+ }
215
+ }
0 commit comments