annotate API/Objects/Requirement/Validation.cs @ 497:cd367acd7c48 default tip

Re #419: Remove assumptions of a file-based install * Swap XSLTs to resources * Update XSL Exporter to use Streams, not files
author IBBoard <dev@ibboard.co.uk>
date Wed, 28 Nov 2012 20:24:36 +0000
parents 47acc63cf529
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
354
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
1 // This file (Validation.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
2 //
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
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.
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
4 using System;
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
5
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
6 namespace IBBoard.WarFoundry.API.Objects.Requirement
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
7 {
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
8 /// <summary>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
9 /// A custom enum for validation to distinguish between "validation wasn't necessary" and "validation passed".
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
10 /// This should allow for easier handling of failed requirements later being satisfied.
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
11 /// </summary>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
12 public enum Validation
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
13 {
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
14 Passed = 1,
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
15 Failed = 2,
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
16 NotApplicable = 3
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
17 }
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
18
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
19 /// <summary>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
20 /// A helper class to handle the enums and treat them as booleans where a pass/fail is all that is necessary.
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
21 /// </summary>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
22 public class Validates
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
23 {
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
24 /// <summary>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
25 /// Checks if the validation was okay (pass or not applicable)
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
26 /// </summary>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
27 /// <returns>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
28 /// <code>true</code> if the validation passed or was not applicable, else <code>false</code>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
29 /// </returns>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
30 /// <param name='passed'>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
31 /// The Validation enum value to check
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
32 /// </param>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
33 public static bool AsOkay(Validation result)
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
34 {
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
35 return (result & Validation.Passed) == Validation.Passed;
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
36 }
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
37
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
38 /// <summary>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
39 /// Checks if the validation result was not okay (failed or not applicable). Note that this is different
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
40 /// to <code>!Validates.AsOkay(result)</code> because this method treats not applicable as not being okay.
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
41 /// </summary>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
42 /// <returns>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
43 /// <code>true</code> if the validation failed or was not applicable, else <code>false</code>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
44 /// </returns>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
45 /// <param name='result'>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
46 /// The Validation enum value to check
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
47 /// </param>
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
48 public static bool AsNotOkay (Validation result)
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
49 {
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
50 return (result & Validation.Failed) == Validation.Failed;
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
51 }
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
52 }
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
53 }
47acc63cf529 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 339
diff changeset
54