annotate API/Objects/Requirement/Validation.cs @ 346:b0ba1d25f51e

* Set target framework to v2.0...AGAIN no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sat, 09 Apr 2011 15:14:16 +0000
parents 50cd43bf51b3
children 47acc63cf529
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
339
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (Validation.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 namespace IBBoard.WarFoundry.API.Objects.Requirement
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 {
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 /// <summary>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 /// A custom enum for validation to distinguish between "validation wasn't necessary" and "validation passed".
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 /// This should allow for easier handling of failed requirements later being satisfied.
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 /// </summary>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public enum Validation
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 Passed = 1,
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 Failed = 2,
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 NotApplicable = 3
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 }
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 /// <summary>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 /// A helper class to handle the enums and treat them as booleans where a pass/fail is all that is necessary.
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 /// </summary>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 public class Validates
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 {
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 /// <summary>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 /// Checks if the validation was okay (pass or not applicable)
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 /// </summary>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 /// <returns>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 /// <code>true</code> if the validation passed or was not applicable, else <code>false</code>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 /// </returns>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 /// <param name='passed'>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 /// The Validation enum value to check
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 /// </param>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 public static bool AsOkay(Validation result)
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 {
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 return (result | Validation.Passed) == Validation.Passed;
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 }
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 /// <summary>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 /// Checks if the validation result was not okay (failed or not applicable). Note that this is different
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 /// to <code>!Validates.AsOkay(result)</code> because this method treats not applicable as not being okay.
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 /// </summary>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 /// <returns>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 /// <code>true</code> if the validation failed or was not applicable, else <code>false</code>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 /// </returns>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 /// <param name='result'>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 /// The Validation enum value to check
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 /// </param>
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 public static bool AsNotOkay (Validation result)
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 {
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 return (result | Validation.Failed) == Validation.Failed;
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 }
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 }
50cd43bf51b3 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54