diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.Conversions.cs b/X10D/src/BooleanExtensions/BooleanExtensions.Conversions.cs deleted file mode 100644 index e43b204..0000000 --- a/X10D/src/BooleanExtensions/BooleanExtensions.Conversions.cs +++ /dev/null @@ -1,209 +0,0 @@ - -namespace X10D.BooleanExtensions -{ - public static partial class BooleanExtensions - { - /// - /// Converts the current Boolean value to the equivalent 8-bit unsigned integer. - /// - /// The Boolean value to convert. - /// - /// 1 if is - /// -or- - /// 0 otherwise. - /// - /// - /// The following example illustrates the conversion of to values. - /// - /// bool falseFlag = false; - /// bool trueFlag = true; - /// - /// Console.WriteLine("{0} converts to {1}.", falseFlag, - /// falseFlag.ToByte()); - /// Console.WriteLine("{0} converts to {1}.", trueFlag, - /// trueFlag.ToByte()); - /// // The example displays the following output: - /// // False converts to 0. - /// // True converts to 1. - /// - /// - public static byte ToByte(this bool value) - { - return value ? 1 : 0; - } - - /// - /// Converts the current Boolean value to the equivalent decimal number. - /// - /// The Boolean value to convert. - /// - /// 1 if is - /// -or- - /// 0 otherwise. - /// - /// - /// The following example illustrates the conversion of to values. - /// - /// bool falseFlag = false; - /// bool trueFlag = true; - /// - /// Console.WriteLine("{0} converts to {1}.", falseFlag, - /// falseFlag.ToDouble()); - /// Console.WriteLine("{0} converts to {1}.", trueFlag, - /// trueFlag.ToDouble()); - /// // The example displays the following output: - /// // False converts to 0. - /// // True converts to 1. - /// - /// - public static decimal ToDecimal(this bool value) - { - return value.ToByte(); - } - - /// - /// Converts the current Boolean value to the equivalent double-precision floating-point number. - /// - /// The Boolean value to convert. - /// - /// 1 if is - /// -or- - /// 0 otherwise. - /// - /// - /// The following example illustrates the conversion of to values. - /// - /// bool falseFlag = false; - /// bool trueFlag = true; - /// - /// Console.WriteLine("{0} converts to {1}.", falseFlag, - /// falseFlag.ToDouble()); - /// Console.WriteLine("{0} converts to {1}.", trueFlag, - /// trueFlag.ToDouble()); - /// // The example displays the following output: - /// // False converts to 0. - /// // True converts to 1. - /// - /// - public static long ToDouble(this bool value) - { - return value.ToByte(); - } - - /// - /// Converts the current Boolean value to the equivalent 16-bit signed integer. - /// - /// The Boolean value to convert. - /// - /// 1 if is - /// -or- - /// 0 otherwise. - /// - /// - /// The following example illustrates the conversion of to values. - /// - /// bool falseFlag = false; - /// bool trueFlag = true; - /// - /// Console.WriteLine("{0} converts to {1}.", falseFlag, - /// falseFlag.ToInt16()); - /// Console.WriteLine("{0} converts to {1}.", trueFlag, - /// trueFlag.ToInt16()); - /// // The example displays the following output: - /// // False converts to 0. - /// // True converts to 1. - /// - /// - public static short ToInt16(this bool value) - { - return value.ToByte(); - } - - /// - /// Converts the current Boolean value to the equivalent 32-bit signed integer. - /// - /// The Boolean value to convert. - /// - /// 1 if is - /// -or- - /// 0 otherwise. - /// - /// - /// The following example illustrates the conversion of to values. - /// - /// bool falseFlag = false; - /// bool trueFlag = true; - /// - /// Console.WriteLine("{0} converts to {1}.", falseFlag, - /// falseFlag.ToInt32()); - /// Console.WriteLine("{0} converts to {1}.", trueFlag, - /// trueFlag.ToInt32()); - /// // The example displays the following output: - /// // False converts to 0. - /// // True converts to 1. - /// - /// - public static int ToInt32(this bool value) - { - return value.ToByte(); - } - - /// - /// Converts the current Boolean value to the equivalent 64-bit signed integer. - /// - /// The Boolean value to convert. - /// - /// 1 if is - /// -or- - /// 0 otherwise. - /// - /// - /// The following example illustrates the conversion of to values. - /// - /// bool falseFlag = false; - /// bool trueFlag = true; - /// - /// Console.WriteLine("{0} converts to {1}.", falseFlag, - /// falseFlag.ToInt64()); - /// Console.WriteLine("{0} converts to {1}.", trueFlag, - /// trueFlag.ToInt64()); - /// // The example displays the following output: - /// // False converts to 0. - /// // True converts to 1. - /// - /// - public static long ToInt64(this bool value) - { - return value.ToByte(); - } - - /// - /// Converts the current Boolean value to the equivalent single-precision floating-point number. - /// - /// The Boolean value to convert. - /// - /// 1 if is - /// -or- - /// 0 otherwise. - /// - /// - /// The following example illustrates the conversion of to values. - /// - /// bool falseFlag = false; - /// bool trueFlag = true; - /// - /// Console.WriteLine("{0} converts to {1}.", falseFlag, - /// falseFlag.ToSingle()); - /// Console.WriteLine("{0} converts to {1}.", trueFlag, - /// trueFlag.ToSingle()); - /// // The example displays the following output: - /// // False converts to 0. - /// // True converts to 1. - /// - /// - public static float ToSingle(this bool value) - { - return value.ToByte(); - } - } -} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.Conversions.Unsigned.cs b/X10D/src/BooleanExtensions/BooleanExtensions.Unsigned.cs similarity index 100% rename from X10D/src/BooleanExtensions/BooleanExtensions.Conversions.Unsigned.cs rename to X10D/src/BooleanExtensions/BooleanExtensions.Unsigned.cs diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.cs b/X10D/src/BooleanExtensions/BooleanExtensions.cs index 706eb4b..54f8161 100644 --- a/X10D/src/BooleanExtensions/BooleanExtensions.cs +++ b/X10D/src/BooleanExtensions/BooleanExtensions.cs @@ -1,9 +1,223 @@ -namespace X10D.BooleanExtensions +using System; + +namespace X10D.BooleanExtensions { /// /// Extension methods for . /// public static partial class BooleanExtensions { + /// + /// Returns the current Boolean value as a byte array. + /// + /// The Boolean value. + /// A byte array with length 1. + public static byte[] GetBytes(this bool value) + { + return BitConverter.GetBytes(value); + } + + /// + /// Converts the current Boolean value to the equivalent 8-bit unsigned integer. + /// + /// The Boolean value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + /// + /// The following example illustrates the conversion of to values. + /// + /// bool falseFlag = false; + /// bool trueFlag = true; + /// + /// Console.WriteLine("{0} converts to {1}.", falseFlag, + /// falseFlag.ToByte()); + /// Console.WriteLine("{0} converts to {1}.", trueFlag, + /// trueFlag.ToByte()); + /// // The example displays the following output: + /// // False converts to 0. + /// // True converts to 1. + /// + /// + public static byte ToByte(this bool value) + { + return value ? 1 : 0; + } + + /// + /// Converts the current Boolean value to the equivalent decimal number. + /// + /// The Boolean value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + /// + /// The following example illustrates the conversion of to values. + /// + /// bool falseFlag = false; + /// bool trueFlag = true; + /// + /// Console.WriteLine("{0} converts to {1}.", falseFlag, + /// falseFlag.ToDouble()); + /// Console.WriteLine("{0} converts to {1}.", trueFlag, + /// trueFlag.ToDouble()); + /// // The example displays the following output: + /// // False converts to 0. + /// // True converts to 1. + /// + /// + public static decimal ToDecimal(this bool value) + { + return value.ToByte(); + } + + /// + /// Converts the current Boolean value to the equivalent double-precision floating-point number. + /// + /// The Boolean value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + /// + /// The following example illustrates the conversion of to values. + /// + /// bool falseFlag = false; + /// bool trueFlag = true; + /// + /// Console.WriteLine("{0} converts to {1}.", falseFlag, + /// falseFlag.ToDouble()); + /// Console.WriteLine("{0} converts to {1}.", trueFlag, + /// trueFlag.ToDouble()); + /// // The example displays the following output: + /// // False converts to 0. + /// // True converts to 1. + /// + /// + public static long ToDouble(this bool value) + { + return value.ToByte(); + } + + /// + /// Converts the current Boolean value to the equivalent 16-bit signed integer. + /// + /// The Boolean value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + /// + /// The following example illustrates the conversion of to values. + /// + /// bool falseFlag = false; + /// bool trueFlag = true; + /// + /// Console.WriteLine("{0} converts to {1}.", falseFlag, + /// falseFlag.ToInt16()); + /// Console.WriteLine("{0} converts to {1}.", trueFlag, + /// trueFlag.ToInt16()); + /// // The example displays the following output: + /// // False converts to 0. + /// // True converts to 1. + /// + /// + public static short ToInt16(this bool value) + { + return value.ToByte(); + } + + /// + /// Converts the current Boolean value to the equivalent 32-bit signed integer. + /// + /// The Boolean value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + /// + /// The following example illustrates the conversion of to values. + /// + /// bool falseFlag = false; + /// bool trueFlag = true; + /// + /// Console.WriteLine("{0} converts to {1}.", falseFlag, + /// falseFlag.ToInt32()); + /// Console.WriteLine("{0} converts to {1}.", trueFlag, + /// trueFlag.ToInt32()); + /// // The example displays the following output: + /// // False converts to 0. + /// // True converts to 1. + /// + /// + public static int ToInt32(this bool value) + { + return value.ToByte(); + } + + /// + /// Converts the current Boolean value to the equivalent 64-bit signed integer. + /// + /// The Boolean value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + /// + /// The following example illustrates the conversion of to values. + /// + /// bool falseFlag = false; + /// bool trueFlag = true; + /// + /// Console.WriteLine("{0} converts to {1}.", falseFlag, + /// falseFlag.ToInt64()); + /// Console.WriteLine("{0} converts to {1}.", trueFlag, + /// trueFlag.ToInt64()); + /// // The example displays the following output: + /// // False converts to 0. + /// // True converts to 1. + /// + /// + public static long ToInt64(this bool value) + { + return value.ToByte(); + } + + /// + /// Converts the current Boolean value to the equivalent single-precision floating-point number. + /// + /// The Boolean value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + /// + /// The following example illustrates the conversion of to values. + /// + /// bool falseFlag = false; + /// bool trueFlag = true; + /// + /// Console.WriteLine("{0} converts to {1}.", falseFlag, + /// falseFlag.ToSingle()); + /// Console.WriteLine("{0} converts to {1}.", trueFlag, + /// trueFlag.ToSingle()); + /// // The example displays the following output: + /// // False converts to 0. + /// // True converts to 1. + /// + /// + public static float ToSingle(this bool value) + { + return value.ToByte(); + } } }