mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 19:48:46 +00:00
parent
db5512db59
commit
17f6a05c48
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToByte.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToByte.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToDecimal.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToDecimal.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToDouble.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToDouble.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToInt16.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToInt16.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToInt32.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToInt32.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToInt64.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToInt64.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToSingle.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToSingle.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToUInt16.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToUInt16.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToUInt32.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToUInt32.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
19
X10D/src/BooleanExtensions/BooleanExtensions.ToUInt64.cs
Normal file
19
X10D/src/BooleanExtensions/BooleanExtensions.ToUInt64.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
9
X10D/src/BooleanExtensions/BooleanExtensions.cs
Normal file
9
X10D/src/BooleanExtensions/BooleanExtensions.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace X10D.BooleanExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="bool" />.
|
||||
/// </summary>
|
||||
public static partial class BooleanExtensions
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user