1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 19:48:46 +00:00

🚚 Move BooleanExtensions to child namespace

Item for #15, #17 and #19
This commit is contained in:
Oliver Booth 2021-01-17 02:37:59 +00:00
parent db5512db59
commit 17f6a05c48
12 changed files with 199 additions and 48 deletions

View File

@ -1,48 +0,0 @@
namespace X10D
{
/// <summary>
/// Extension methods for <see cref="bool" />.
/// </summary>
public static class BooleanExtensions
{
/// <summary>
/// Gets the value of this boolean as represented by <see cref="byte" />.
/// </summary>
/// <param name="value">The boolean.</param>
/// <returns>Returns 1 if <paramref name="value" /> is <see langword="true" />, or 0 otherwise.</returns>
public static byte ToByte(this bool value)
{
return value ? 1 : 0;
}
/// <summary>
/// Gets the value of this boolean as represented by <see cref="short" />.
/// </summary>
/// <param name="value">The boolean.</param>
/// <returns>Returns 1 if <paramref name="value" /> is <see langword="true" />, or 0 otherwise.</returns>
public static short ToInt16(this bool value)
{
return value.ToByte();
}
/// <summary>
/// Gets the value of this boolean as represented by <see cref="int" />.
/// </summary>
/// <param name="value">The boolean.</param>
/// <returns>Returns 1 if <paramref name="value" /> is <see langword="true" />, or 0 otherwise.</returns>
public static int ToInt32(this bool value)
{
return value.ToByte();
}
/// <summary>
/// Gets the value of this boolean as represented by <see cref="long" />.
/// </summary>
/// <param name="value">The boolean.</param>
/// <returns>Returns 1 if <paramref name="value" /> is <see langword="true" />, 0 otherwise.</returns>
public static long ToInt64(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to a 1-byte unsigned integer representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static byte ToByte(this bool value)
{
return value ? 1 : 0;
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to a decimal floating-point number representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static decimal ToDecimal(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to a double-precision floating-point number representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static long ToDouble(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to a 2-byte signed integer representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static short ToInt16(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to a 4-byte signed integer representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static int ToInt32(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to an 8-byte signed integer representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static long ToInt64(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to a single-precision floating-point number representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static float ToSingle(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to a 2-byte unsigned integer representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static ushort ToUInt16(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to a 4-byte unsigned integer representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static uint ToUInt32(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,19 @@
namespace X10D.BooleanExtensions
{
public static partial class BooleanExtensions
{
/// <summary>
/// Converts the current <see cref="bool" /> to an 8-byte unsigned integer representing its truthiness.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <c>1</c> if <paramref name="value" /> is <see langword="true"/>
/// -or-
/// <c>0</c> otherwise.
/// </returns>
public static ulong ToUInt64(this bool value)
{
return value.ToByte();
}
}
}

View File

@ -0,0 +1,9 @@
namespace X10D.BooleanExtensions
{
/// <summary>
/// Extension methods for <see cref="bool" />.
/// </summary>
public static partial class BooleanExtensions
{
}
}