4
* RSS.NET (http://rss-net.sf.net/)
5
* Copyright � 2002, 2003 George Tsiokos. All Rights Reserved.
7
* RSS 2.0 (http://blogs.law.harvard.edu/tech/rss)
8
* RSS 2.0 is offered by the Berkman Center for Internet & Society at
9
* Harvard Law School under the terms of the Attribution/Share Alike
10
* Creative Commons license.
12
* Permission is hereby granted, free of charge, to any person obtaining
13
* a copy of this software and associated documentation files (the "Software"),
14
* to deal in the Software without restriction, including without limitation
15
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
* and/or sell copies of the Software, and to permit persons to whom the
17
* Software is furnished to do so, subject to the following conditions:
19
* The above copyright notice and this permission notice shall be included in all
20
* copies or substantial portions of the Software.
22
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34
/// <summary>Represents Null, False, and True</summary>
35
/// <remarks>Source: Microsoft c# example</remarks>
39
/// <summary>A DBBool containing 'Null'.</summary>
40
/// <remarks>One of three possible DBBool values.</remarks>
41
public static readonly DBBool Null = new DBBool(0);
42
/// <summary>A DBBool containing 'False'.</summary>
43
/// <remarks>One of three possible DBBool values.</remarks>
44
public static readonly DBBool False = new DBBool(-1);
45
/// <summary>A DBBool containing 'True'.</summary>
46
/// <remarks>One of three possible DBBool values.</remarks>
47
public static readonly DBBool True = new DBBool(1);
48
/// <summary>Private field that stores �1, 0, 1 for False, Null, True.</summary>
50
/// <summary>Private instance constructor. The value parameter must be �1, 0, or 1.</summary>
53
this.value = (sbyte)value;
55
/// <summary>Properties to examine the value of a DBBool.</summary>
56
/// <remarks>Return true if this DBBool has the given value, false otherwise.</remarks>
57
public bool IsNull { get { return value == 0; } }
58
/// <summary>Properties to examine the value of a DBBool.</summary>
59
/// <remarks>Return true if this DBBool has the given value, false otherwise.</remarks>
60
public bool IsFalse { get { return value < 0; } }
61
/// <summary>Properties to examine the value of a DBBool.</summary>
62
/// <remarks>Return true if this DBBool has the given value, false otherwise.</remarks>
63
public bool IsTrue { get { return value > 0; } }
64
/// <summary>Implicit conversion from bool to DBBool. Maps true to DBBool.True and false to DBBool.False.</summary>
65
/// <param name="x">a DBBool</param>
66
public static implicit operator DBBool(bool x)
68
return x? True: False;
70
/// <summary>Explicit conversion from DBBool to bool.</summary>
71
/// <exception cref="InvalidOperationException">The given DBBool is Null</exception>
72
/// <param name="x">a DBBool</param>
73
/// <returns>true or false</returns>
74
public static explicit operator bool(DBBool x)
76
if (x.value == 0) throw new InvalidOperationException();
79
/// <summary>Equality operator.</summary>
80
/// <param name="x">a DBBool</param>
81
/// <param name="y">a DBBool</param>
82
/// <returns>Returns Null if either operand is Null, otherwise returns True or False.</returns>
83
public static DBBool operator ==(DBBool x, DBBool y)
85
if (x.value == 0 || y.value == 0) return Null;
86
return x.value == y.value? True: False;
88
/// <summary>Inequality operator.</summary>
89
/// <param name="x">a DBBool</param>
90
/// <param name="y">a DBBool</param>
91
/// <returns>Returns Null if either operand is Null, otherwise returns True or False.</returns>
92
public static DBBool operator !=(DBBool x, DBBool y)
94
if (x.value == 0 || y.value == 0) return Null;
95
return x.value != y.value? True: False;
97
/// <summary>Logical negation operator.</summary>
98
/// <param name="x">a DBBool</param>
99
/// <returns>Returns True if the operand is False, Null if the operand is Null, or False if the operand is True.</returns>
100
public static DBBool operator !(DBBool x)
102
return new DBBool(-x.value);
104
/// <summary>Logical AND operator.</summary>
105
/// <param name="x">a DBBool</param>
106
/// <param name="y">a DBBool</param>
107
/// <returns>Returns False if either operand is False, otherwise Null if either operand is Null, otherwise True.</returns>
108
public static DBBool operator &(DBBool x, DBBool y)
110
return new DBBool(x.value < y.value? x.value: y.value);
112
/// <summary>Logical OR operator.</summary>
113
/// <param name="x">a DBBool</param>
114
/// <param name="y">a DBBool</param>
115
/// <returns>Returns True if either operand is True, otherwise Null if either operand is Null, otherwise False.</returns>
116
public static DBBool operator |(DBBool x, DBBool y)
118
return new DBBool(x.value > y.value? x.value: y.value);
120
/// <summary>Definitely true operator.</summary>
121
/// <param name="x">a DBBool</param>
122
/// <returns>Returns true if the operand is True, false otherwise.</returns>
123
public static bool operator true(DBBool x)
127
/// <summary>Definitely false operator.</summary>
128
/// <param name="x">a DBBool</param>
129
/// <returns>Returns true if the operand is False, false otherwise.</returns>
130
public static bool operator false(DBBool x)
134
/// <summary>Determines whether two DBBool instances are equal.</summary>
135
/// <param name="o">The object to check.</param>
136
/// <returns>True if the two DBBools are equal.</returns>
137
public override bool Equals(object o)
141
return (bool) (this == (DBBool) o);
148
/// <summary>Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.</summary>
149
/// <returns>A hash code for the current DBBool.</returns>
150
public override int GetHashCode()
154
/// <summary>Returns a string representation of the current Object.</summary>
155
/// <exception cref="InvalidOperationException">Object has not been initialized.</exception>
156
/// <returns>A string containing DBBool.False, DBBool.Null, or DBBool.True</returns>
157
public override string ToString()
162
return "DBBool.False";
164
return "DBBool.Null";
166
return "DBBool.True";
168
throw new InvalidOperationException();