changeset 354:47acc63cf529

Re #27: Unit requirements * Bit mask the values with a bitwise AND rather than an OR
author IBBoard <dev@ibboard.co.uk>
date Fri, 22 Apr 2011 10:38:03 +0000
parents 65fccdd51aec
children 47712a323cf2
files API/Objects/Requirement/Validation.cs
diffstat 1 files changed, 54 insertions(+), 54 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/Validation.cs	Sun Apr 17 20:08:43 2011 +0000
     1.2 +++ b/API/Objects/Requirement/Validation.cs	Fri Apr 22 10:38:03 2011 +0000
     1.3 @@ -1,54 +1,54 @@
     1.4 -// This file (Validation.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard
     1.5 -//
     1.6 -// 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.
     1.7 -using System;
     1.8 -
     1.9 -namespace IBBoard.WarFoundry.API.Objects.Requirement
    1.10 -{
    1.11 -	/// <summary>
    1.12 -	/// A custom enum for validation to distinguish between "validation wasn't necessary" and "validation passed".
    1.13 -	/// This should allow for easier handling of failed requirements later being satisfied.
    1.14 -	/// </summary>
    1.15 -	public enum Validation
    1.16 -	{
    1.17 -		Passed = 1,
    1.18 -		Failed = 2,
    1.19 -		NotApplicable = 3
    1.20 -	}
    1.21 -
    1.22 -	/// <summary>
    1.23 -	/// A helper class to handle the enums and treat them as booleans where a pass/fail is all that is necessary.
    1.24 -	/// </summary>
    1.25 -	public class Validates
    1.26 -	{
    1.27 -		/// <summary>
    1.28 -		/// Checks if the validation was okay (pass or not applicable)
    1.29 -		/// </summary>
    1.30 -		/// <returns>
    1.31 -		/// <code>true</code> if the validation passed or was not applicable, else <code>false</code>
    1.32 -		/// </returns>
    1.33 -		/// <param name='passed'>
    1.34 -		/// The Validation enum value to check
    1.35 -		/// </param>
    1.36 -		public static bool AsOkay(Validation result)
    1.37 -		{
    1.38 -			return (result | Validation.Passed) == Validation.Passed;
    1.39 -		}
    1.40 -
    1.41 -		/// <summary>
    1.42 -		/// Checks if the validation result was not okay (failed or not applicable). Note that this is different
    1.43 -		/// to <code>!Validates.AsOkay(result)</code> because this method treats not applicable as not being okay.
    1.44 -		/// </summary>
    1.45 -		/// <returns>
    1.46 -		/// <code>true</code> if the validation failed or was not applicable, else <code>false</code>
    1.47 -		/// </returns>
    1.48 -		/// <param name='result'>
    1.49 -		/// The Validation enum value to check
    1.50 -		/// </param>
    1.51 -		public static bool AsNotOkay (Validation result)
    1.52 -		{
    1.53 -			return (result | Validation.Failed) == Validation.Failed;
    1.54 -		}
    1.55 -	}
    1.56 -}
    1.57 -
    1.58 +// This file (Validation.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard
    1.59 +//
    1.60 +// 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.
    1.61 +using System;
    1.62 +
    1.63 +namespace IBBoard.WarFoundry.API.Objects.Requirement
    1.64 +{
    1.65 +	/// <summary>
    1.66 +	/// A custom enum for validation to distinguish between "validation wasn't necessary" and "validation passed".
    1.67 +	/// This should allow for easier handling of failed requirements later being satisfied.
    1.68 +	/// </summary>
    1.69 +	public enum Validation
    1.70 +	{
    1.71 +		Passed = 1,
    1.72 +		Failed = 2,
    1.73 +		NotApplicable = 3
    1.74 +	}
    1.75 +
    1.76 +	/// <summary>
    1.77 +	/// A helper class to handle the enums and treat them as booleans where a pass/fail is all that is necessary.
    1.78 +	/// </summary>
    1.79 +	public class Validates
    1.80 +	{
    1.81 +		/// <summary>
    1.82 +		/// Checks if the validation was okay (pass or not applicable)
    1.83 +		/// </summary>
    1.84 +		/// <returns>
    1.85 +		/// <code>true</code> if the validation passed or was not applicable, else <code>false</code>
    1.86 +		/// </returns>
    1.87 +		/// <param name='passed'>
    1.88 +		/// The Validation enum value to check
    1.89 +		/// </param>
    1.90 +		public static bool AsOkay(Validation result)
    1.91 +		{
    1.92 +			return (result & Validation.Passed) == Validation.Passed;
    1.93 +		}
    1.94 +
    1.95 +		/// <summary>
    1.96 +		/// Checks if the validation result was not okay (failed or not applicable). Note that this is different
    1.97 +		/// to <code>!Validates.AsOkay(result)</code> because this method treats not applicable as not being okay.
    1.98 +		/// </summary>
    1.99 +		/// <returns>
   1.100 +		/// <code>true</code> if the validation failed or was not applicable, else <code>false</code>
   1.101 +		/// </returns>
   1.102 +		/// <param name='result'>
   1.103 +		/// The Validation enum value to check
   1.104 +		/// </param>
   1.105 +		public static bool AsNotOkay (Validation result)
   1.106 +		{
   1.107 +			return (result & Validation.Failed) == Validation.Failed;
   1.108 +		}
   1.109 +	}
   1.110 +}
   1.111 +