From 17f6a05c481ed50c5421ab40dc3e90bb9b73cc66 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sun, 17 Jan 2021 02:37:59 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Move=20BooleanExtensions=20to=20?= =?UTF-8?q?child=20namespace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Item for #15, #17 and #19 --- X10D/src/BooleanExtensions.cs | 48 ------------------- .../BooleanExtensions.ToByte.cs | 19 ++++++++ .../BooleanExtensions.ToDecimal.cs | 19 ++++++++ .../BooleanExtensions.ToDouble.cs | 19 ++++++++ .../BooleanExtensions.ToInt16.cs | 19 ++++++++ .../BooleanExtensions.ToInt32.cs | 19 ++++++++ .../BooleanExtensions.ToInt64.cs | 19 ++++++++ .../BooleanExtensions.ToSingle.cs | 19 ++++++++ .../BooleanExtensions.ToUInt16.cs | 19 ++++++++ .../BooleanExtensions.ToUInt32.cs | 19 ++++++++ .../BooleanExtensions.ToUInt64.cs | 19 ++++++++ .../BooleanExtensions/BooleanExtensions.cs | 9 ++++ 12 files changed, 199 insertions(+), 48 deletions(-) delete mode 100644 X10D/src/BooleanExtensions.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToByte.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToDecimal.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToDouble.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToInt16.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToInt32.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToInt64.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToSingle.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToUInt16.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToUInt32.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.ToUInt64.cs create mode 100644 X10D/src/BooleanExtensions/BooleanExtensions.cs diff --git a/X10D/src/BooleanExtensions.cs b/X10D/src/BooleanExtensions.cs deleted file mode 100644 index 1d81fda..0000000 --- a/X10D/src/BooleanExtensions.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace X10D -{ - /// - /// Extension methods for . - /// - public static class BooleanExtensions - { - /// - /// Gets the value of this boolean as represented by . - /// - /// The boolean. - /// Returns 1 if is , or 0 otherwise. - public static byte ToByte(this bool value) - { - return value ? 1 : 0; - } - - /// - /// Gets the value of this boolean as represented by . - /// - /// The boolean. - /// Returns 1 if is , or 0 otherwise. - public static short ToInt16(this bool value) - { - return value.ToByte(); - } - - /// - /// Gets the value of this boolean as represented by . - /// - /// The boolean. - /// Returns 1 if is , or 0 otherwise. - public static int ToInt32(this bool value) - { - return value.ToByte(); - } - - /// - /// Gets the value of this boolean as represented by . - /// - /// The boolean. - /// Returns 1 if is , 0 otherwise. - public static long ToInt64(this bool value) - { - return value.ToByte(); - } - } -} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToByte.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToByte.cs new file mode 100644 index 0000000..248de01 --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToByte.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to a 1-byte unsigned integer representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static byte ToByte(this bool value) + { + return value ? 1 : 0; + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToDecimal.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToDecimal.cs new file mode 100644 index 0000000..aba4031 --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToDecimal.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to a decimal floating-point number representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static decimal ToDecimal(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToDouble.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToDouble.cs new file mode 100644 index 0000000..6532dbb --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToDouble.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to a double-precision floating-point number representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static long ToDouble(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToInt16.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToInt16.cs new file mode 100644 index 0000000..bea5419 --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToInt16.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to a 2-byte signed integer representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static short ToInt16(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToInt32.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToInt32.cs new file mode 100644 index 0000000..d98015d --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToInt32.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to a 4-byte signed integer representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static int ToInt32(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToInt64.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToInt64.cs new file mode 100644 index 0000000..aae2858 --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToInt64.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to an 8-byte signed integer representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static long ToInt64(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToSingle.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToSingle.cs new file mode 100644 index 0000000..9dba0ea --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToSingle.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to a single-precision floating-point number representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static float ToSingle(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt16.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt16.cs new file mode 100644 index 0000000..32bd726 --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt16.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to a 2-byte unsigned integer representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static ushort ToUInt16(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt32.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt32.cs new file mode 100644 index 0000000..2f7ece7 --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt32.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to a 4-byte unsigned integer representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static uint ToUInt32(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt64.cs b/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt64.cs new file mode 100644 index 0000000..1acdf19 --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.ToUInt64.cs @@ -0,0 +1,19 @@ +namespace X10D.BooleanExtensions +{ + public static partial class BooleanExtensions + { + /// + /// Converts the current to an 8-byte unsigned integer representing its truthiness. + /// + /// The value to convert. + /// + /// 1 if is + /// -or- + /// 0 otherwise. + /// + public static ulong ToUInt64(this bool value) + { + return value.ToByte(); + } + } +} diff --git a/X10D/src/BooleanExtensions/BooleanExtensions.cs b/X10D/src/BooleanExtensions/BooleanExtensions.cs new file mode 100644 index 0000000..706eb4b --- /dev/null +++ b/X10D/src/BooleanExtensions/BooleanExtensions.cs @@ -0,0 +1,9 @@ +namespace X10D.BooleanExtensions +{ + /// + /// Extension methods for . + /// + public static partial class BooleanExtensions + { + } +}