File: VerificationAttribute.cs

package info (click to toggle)
mono 6.8.0.105%2Bdfsg-3.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,284,512 kB
  • sloc: cs: 11,172,132; xml: 2,850,069; ansic: 671,653; cpp: 122,091; perl: 59,366; javascript: 30,841; asm: 22,168; makefile: 20,093; sh: 15,020; python: 4,827; pascal: 925; sql: 859; sed: 16; php: 1
file content (243 lines) | stat: -rw-r--r-- 8,549 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
//------------------------------------------------------------------------------
// <copyright file="VerificationAttribute.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace System.Web.UI {

    using System;
    using System.ComponentModel;

    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple=true)]
    public sealed class VerificationAttribute : Attribute {

        private string _guideline;       //  "WCAG 1.1", "ADA508"
        private string _checkpoint;      //10.1: in rule and used by checker
        private VerificationReportLevel _reportLevel;//VerificationReportLevel.Error| Warning| Guideline
        private int _priority;           //1,2,3,4
        private string _message;         //"something is in error"
        private VerificationRule _rule;  //VerificationRule.Required | Prohibited
        private string _conditionalProperty; //"foo"
        private VerificationConditionalOperator _conditionalOperator; //VerificationConditionalOperator.Equals | NotEquals
        private string _conditionalValue; //eg. String.Empty 
        private string _guidelineUrl;

        /* minimal constructor
         * implies  VerificationRule.Equals
         *          ConditionalProperty = String.Empty
         *          VerificationConditionalOperator.Equals
         *          ConditionalValue = String.Empty
         *          GuidelineUrl = String.Empty
         */
        public VerificationAttribute (
                    string guideline,
                    string checkpoint,
                    VerificationReportLevel reportLevel,
                    int priority,
                    string message) : 
                        this(guideline, 
                             checkpoint, 
                             reportLevel, 
                             priority, 
                             message, 
                             VerificationRule.Required, /*VerificationRule*/
                             String.Empty, /*ConditionalProperty*/
                             VerificationConditionalOperator.Equals, 
                             String.Empty, /*ConditionalValue*/
                             String.Empty /*GuidelineUrl*/) {
        }

        /* constructor that implies
         *      ConditionalProperty = String.Empty
         *      VerificationConditionalOperator.Equals
         *      ConditionalValue = String.Empty
         *      GuidelineUrl = String.Empty
         */
        /*
        public VerificationAttribute (
                    string guideline,
                    string checkpoint,
                    VerificationReportLevel reportLevel,
                    int priority,
                    string message,
                    VerificationRule rule) : 
                        this(guideline,
                             checkpoint,
                             reportLevel,
                             priority,
                             message,
                             rule,
                             String.Empty, //ConditionalProperty
                             VerificationConditionalOperator.Equals,
                             String.Empty, //ConditionalValue
                             String.Empty) { //GuidelineUrl
        }

        */

        /*specifying just a ConditionalProperty implies:
         *      VerificationConditionalOperator.NotEquals 
         *      ConditionalValue = String.Empty 
         *      GuidelineUrl = String.Empty
         */
        public VerificationAttribute (
                    string guideline,
                    string checkpoint,
                    VerificationReportLevel reportLevel,
                    int priority,
                    string message,
                    VerificationRule rule,
                    string conditionalProperty) : 
                        this(guideline,
                             checkpoint,
                             reportLevel,
                             priority,
                             message,
                             rule, 
                             conditionalProperty,
                             VerificationConditionalOperator.NotEquals,
                             String.Empty, /*ConditionalValue*/
                             String.Empty /*GuidelineUrl*/) {
        }

        /*implies GuidelineUrl = String.Empty */
        internal VerificationAttribute (
                    string guideline,
                    string checkpoint,
                    VerificationReportLevel reportLevel,
                    int priority,
                    string message,
                    VerificationRule rule,
                    string conditionalProperty,
                    VerificationConditionalOperator conditionalOperator,
                    string conditionalValue) : 
                        this(guideline,
                             checkpoint,
                             reportLevel,
                             priority,
                             message,
                             rule,
                             conditionalProperty,
                             conditionalOperator,
                             conditionalValue,
                             String.Empty /*GuidelineUrl*/) {
        }

        public VerificationAttribute(
                    string guideline,
                    string checkpoint,
                    VerificationReportLevel reportLevel,
                    int priority,
                    string message,
                    VerificationRule rule,
                    string conditionalProperty,
                    VerificationConditionalOperator conditionalOperator,
                    string conditionalValue,
                    string guidelineUrl) {

                _guideline = guideline;
                _checkpoint = checkpoint;
                _reportLevel = reportLevel;
                _priority = priority;
                _message = message;
                _rule = rule;
                _conditionalProperty = conditionalProperty;
                _conditionalOperator = conditionalOperator;
                _conditionalValue = conditionalValue;
                _guidelineUrl = guidelineUrl;
        }

        private VerificationAttribute() {
        }

        //WCAG 1.1, ADA508, etc.
        public string Guideline {
            get {
                return _guideline;
            }
        }

        //10.1,  12.4, etc.
        public string Checkpoint {
            get {
                return _checkpoint;
            }
        }

        //VerificationReportLevel.Error | Warning | Guideline
        public VerificationReportLevel VerificationReportLevel {
            get {
                return _reportLevel;
            }
        }

        //1, 2, 3, 4, etc.
        public int Priority {
            get {
                return _priority;
            }
        }

        //message to use if verification rule is true
        public string Message {
            get {
                return _message;
            }
        }

        //VerificationRule.Required | Prohibited
        public VerificationRule VerificationRule {
            get {
                return _rule;
            }
        }

        //name of other control property to condition the assertion
        //used as lhs of conditional expression
        public string ConditionalProperty {
            get {
                return _conditionalProperty;
            }
        }

        //VerificationConditionalOperator.Equals | NotEquals
        //operator to apply to condition statement
        public VerificationConditionalOperator VerificationConditionalOperator {
            get {
                return _conditionalOperator;
            }
        }

        //value to use as rhs in conditional expression
        public string ConditionalValue {
            get {
                return _conditionalValue;
            }
        }

        public string GuidelineUrl {
            get {
                return _guidelineUrl;
            }
        }
    }

    public enum VerificationRule {
        Required,
        Prohibited,
        NotEmptyString
    }

    public enum VerificationReportLevel {
        Error,
        Warning,
        Guideline
    }

    public enum VerificationConditionalOperator {
        Equals,
        NotEquals
    }
}