AP&C API Reference
Public Member Functions | Static Public Member Functions | Properties | List of all members
Apac.Logic.WhyBool Class Reference

WhyBool is a boolean implementation that allows the user to attach a reason for the boolean value. It has been overloaded to allow quick comparison with true System.Boolean values. Using this type of value as a return value from validation-type routines can help keep program flow control from creeping into exception handlers and prevent the need for 'ref' parameters to store the reason for the boolean value. More...

Inheritance diagram for Apac.Logic.WhyBool:

Public Member Functions

 WhyBool ()
 Creates a default WhyBool instance with a value of false and an empty reason. More...
 
 WhyBool (bool value)
 Creates a WhyBool instance with the given value and and empty reason. More...
 
 WhyBool (bool value, string reason)
 Creates a WhyBool with the given value and reason. More...
 
 WhyBool (SerializationInfo info, StreamingContext context)
 Constructor used in binary deserialization. More...
 
bool Equals (WhyBool other)
 Compares two WhyBool instances for equality by comparing their values. The reasons are ignored during this comparison. More...
 
bool Equals (bool other)
 Compares a WhyBool instance for equality with a boolean value by comparing the WhyBool's value to the boolean value. More...
 
override bool Equals (object obj)
 Compares two WhyBool instances for equality by comparing their values. The reasons are ignored during this comparison. More...
 
override int GetHashCode ()
 Returns a hashcode for the WhyBool instance. More...
 
override string ToString ()
 Returns a formatted string showing the value and the reason, if applicable. More...
 
System.Xml.Schema.XmlSchema GetSchema ()
 This method is a no-op. We have opted to use the System.Xml.Serialization.XmlSchemaProviderAttribute instead. More...
 
void ReadXml (System.Xml.XmlReader reader)
 Deserializes object data from XML format. More...
 
void WriteXml (System.Xml.XmlWriter writer)
 Serializes object data to XML format. More...
 
void GetObjectData (SerializationInfo info, StreamingContext context)
 Performs binary object serialization. More...
 

Static Public Member Functions

static bool operator== (WhyBool rhs, WhyBool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator== (WhyBool rhs, bool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator== (bool rhs, WhyBool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator!= (WhyBool rhs, WhyBool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator!= (WhyBool rhs, bool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator!= (bool rhs, WhyBool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator& (bool rhs, WhyBool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator& (WhyBool rhs, bool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator& (WhyBool rhs, WhyBool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator| (bool rhs, WhyBool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator| (WhyBool rhs, bool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static bool operator| (WhyBool rhs, WhyBool lhs)
 Provides logical operator semantics for the WhyBool class. More...
 
static implicit operator Boolean (WhyBool value)
 Implicitly converts a WhyBool to a standard boolean. This is essentially a downcast resulting in the loss of the reason portion of the WhyBool. More...
 
static implicit operator WhyBool (bool value)
 Implicitly converts a boolean value to a WhyBool. This is essentially an upcast that creates a WhyBool with no reason portion supplied. More...
 

Properties

bool Value [get, set]
 The logical value of the WhyBool instance. More...
 
StringBuilder Reason [get, set]
 The reason behind the logical value of the WhyBool instance. More...
 

Detailed Description

WhyBool is a boolean implementation that allows the user to attach a reason for the boolean value. It has been overloaded to allow quick comparison with true System.Boolean values. Using this type of value as a return value from validation-type routines can help keep program flow control from creeping into exception handlers and prevent the need for 'ref' parameters to store the reason for the boolean value.

Constructor & Destructor Documentation

◆ WhyBool() [1/4]

Apac.Logic.WhyBool.WhyBool ( )
inline

Creates a default WhyBool instance with a value of false and an empty reason.

◆ WhyBool() [2/4]

Apac.Logic.WhyBool.WhyBool ( bool  value)
inline

Creates a WhyBool instance with the given value and and empty reason.

Parameters
valueThe logical value of the WhyBool.

◆ WhyBool() [3/4]

Apac.Logic.WhyBool.WhyBool ( bool  value,
string  reason 
)
inline

Creates a WhyBool with the given value and reason.

Parameters
valueThe logical value of the WhyBool.
reasonThe reason behind the logical value.

◆ WhyBool() [4/4]

Apac.Logic.WhyBool.WhyBool ( SerializationInfo  info,
StreamingContext  context 
)
inline

Constructor used in binary deserialization.

Parameters
infoSee SerializationInfo.
contextSee StreamingContext.

Member Function Documentation

◆ Equals() [1/3]

bool Apac.Logic.WhyBool.Equals ( bool  other)
inline

Compares a WhyBool instance for equality with a boolean value by comparing the WhyBool's value to the boolean value.

Parameters
otherThe right-hand-side of the comparison.
Returns
Returns true if the WhyBool value has the same value as the provided boolean, false otherwise.

◆ Equals() [2/3]

override bool Apac.Logic.WhyBool.Equals ( object  obj)
inline

Compares two WhyBool instances for equality by comparing their values. The reasons are ignored during this comparison.

Parameters
objThe right-hand-side of the comparison.
Returns
Returns true if both WhyBool instances have the same value, false otherwise, or if the right-hand-side operand cannot be cast to WhyBool.

◆ Equals() [3/3]

bool Apac.Logic.WhyBool.Equals ( WhyBool  other)
inline

Compares two WhyBool instances for equality by comparing their values. The reasons are ignored during this comparison.

Parameters
otherThe right-hand-side of the comparison.
Returns
Returns true if both WhyBool instances have the same value, false otherwise.

◆ GetHashCode()

override int Apac.Logic.WhyBool.GetHashCode ( )
inline

Returns a hashcode for the WhyBool instance.

Returns

◆ GetObjectData()

void Apac.Logic.WhyBool.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)
inline

Performs binary object serialization.

Parameters
infoSee SerializationInfo.
contextSee StreamingContext.

◆ GetSchema()

System.Xml.Schema.XmlSchema Apac.Logic.WhyBool.GetSchema ( )
inline

This method is a no-op. We have opted to use the System.Xml.Serialization.XmlSchemaProviderAttribute instead.

Returns
Returns null.

◆ operator Boolean()

static implicit Apac.Logic.WhyBool.operator Boolean ( WhyBool  value)
inlinestatic

Implicitly converts a WhyBool to a standard boolean. This is essentially a downcast resulting in the loss of the reason portion of the WhyBool.

Parameters
valueThe WhyBool to be converted.
Returns
The Value property of the WhyBool instance.

◆ operator WhyBool()

static implicit Apac.Logic.WhyBool.operator WhyBool ( bool  value)
inlinestatic

Implicitly converts a boolean value to a WhyBool. This is essentially an upcast that creates a WhyBool with no reason portion supplied.

Parameters
valueThe boolean value to be converted.
Returns
A new WhyBool instance initialized to value .

◆ operator!=() [1/3]

static bool Apac.Logic.WhyBool.operator!= ( bool  rhs,
WhyBool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The inequality of the two operands as indicated by the WhyBool operand's value compared with the boolean operand.

◆ operator!=() [2/3]

static bool Apac.Logic.WhyBool.operator!= ( WhyBool  rhs,
bool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The inequality of the two operands as indicated by the WhyBool operand's value compared with the boolean operand.

◆ operator!=() [3/3]

static bool Apac.Logic.WhyBool.operator!= ( WhyBool  rhs,
WhyBool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The inequality of the two operands as indicated by their values.

◆ operator&() [1/3]

static bool Apac.Logic.WhyBool.operator& ( bool  rhs,
WhyBool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The logical AND of the two operands as indicated by the WhyBool operand's value compared with the boolean operand.

◆ operator&() [2/3]

static bool Apac.Logic.WhyBool.operator& ( WhyBool  rhs,
bool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The logical AND of the two operands as indicated by the WhyBool operand's value compared with the boolean operand.

◆ operator&() [3/3]

static bool Apac.Logic.WhyBool.operator& ( WhyBool  rhs,
WhyBool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The logical AND of the two operands as indicated by the value properties of the two WhyBool operands.

◆ operator==() [1/3]

static bool Apac.Logic.WhyBool.operator== ( bool  rhs,
WhyBool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The equality of the two operands as indicated by the WhyBool operand's value compared with the boolean operand.

◆ operator==() [2/3]

static bool Apac.Logic.WhyBool.operator== ( WhyBool  rhs,
bool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The equality of the two operands as indicated by the WhyBool operand's value compared with the boolean operand.

◆ operator==() [3/3]

static bool Apac.Logic.WhyBool.operator== ( WhyBool  rhs,
WhyBool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The equality of the two operands as indicated by their values.

◆ operator|() [1/3]

static bool Apac.Logic.WhyBool.operator| ( bool  rhs,
WhyBool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The logical OR of the two operands as indicated by the WhyBool operand's value compared with the boolean operand.

◆ operator|() [2/3]

static bool Apac.Logic.WhyBool.operator| ( WhyBool  rhs,
bool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The logical OR of the two operands as indicated by the WhyBool operand's value compared with the boolean operand.

◆ operator|() [3/3]

static bool Apac.Logic.WhyBool.operator| ( WhyBool  rhs,
WhyBool  lhs 
)
inlinestatic

Provides logical operator semantics for the WhyBool class.

Parameters
rhsThe right-hand-side of the operation.
lhsThe left-hand-side of the operation.
Returns
The logical OR of the two operands as indicated by the value properties of the two WhyBool operands.

◆ ReadXml()

void Apac.Logic.WhyBool.ReadXml ( System.Xml.XmlReader  reader)
inline

Deserializes object data from XML format.

Parameters
readerThe System.Xml.XmlReader containing the serialized data.

◆ ToString()

override string Apac.Logic.WhyBool.ToString ( )
inline

Returns a formatted string showing the value and the reason, if applicable.

Returns
A string representation of the WhyBool.

◆ WriteXml()

void Apac.Logic.WhyBool.WriteXml ( System.Xml.XmlWriter  writer)
inline

Serializes object data to XML format.

Parameters
writerThe System.Xml.XmlWriter receiving the serialized data.

Property Documentation

◆ Reason

StringBuilder Apac.Logic.WhyBool.Reason
getset

The reason behind the logical value of the WhyBool instance.

◆ Value

bool Apac.Logic.WhyBool.Value
getset

The logical value of the WhyBool instance.


The documentation for this class was generated from the following file: