mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 19:58:49 +00:00
🔨 Fix SA1121 violation
This commit is contained in:
parent
0b85fa05e4
commit
3afc1d967c
@ -3,7 +3,7 @@
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Boolean"/>.
|
||||
/// Extension methods for <see cref="bool"/>.
|
||||
/// </summary>
|
||||
public static class BooleanExtensions
|
||||
{
|
||||
|
@ -6,15 +6,15 @@
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Byte"/>.
|
||||
/// Extension methods for <see cref="byte"/>.
|
||||
/// </summary>
|
||||
public static class ByteExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a <see cref="String"/> literally representing the raw values in the <see cref="Byte"/>[].
|
||||
/// Gets a <see cref="string"/> literally representing the raw values in the <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to get.</param>
|
||||
/// <returns>Returns a <see cref="String"/>.</returns>
|
||||
/// <returns>Returns a <see cref="string"/>.</returns>
|
||||
public static string AsString(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToString(bytes.ToArray());
|
||||
@ -24,8 +24,8 @@
|
||||
/// Splits <paramref name="bytes"/> into chunks of size <paramref name="chunkSize"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The collection to split.</param>
|
||||
/// <param name="chunkSize">The maximum length of the nested <see cref="Byte"/> collection.</param>
|
||||
/// <returns>Returns an <see cref="IEnumerable{T}"/> of <see cref="IEnumerable{T}"/> of <see cref="Byte"/>
|
||||
/// <param name="chunkSize">The maximum length of the nested <see cref="byte"/> collection.</param>
|
||||
/// <returns>Returns an <see cref="IEnumerable{T}"/> of <see cref="IEnumerable{T}"/> of <see cref="byte"/>
|
||||
/// values.</returns>
|
||||
public static IEnumerable<IEnumerable<byte>> Chunkify(this IEnumerable<byte> bytes, int chunkSize)
|
||||
{
|
||||
@ -43,82 +43,82 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Byte"/>[] to an <see cref="Int16"/>.
|
||||
/// Converts the <see cref="byte"/>[] to an <see cref="short"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="Int16"/>.</returns>
|
||||
/// <returns>Returns an <see cref="short"/>.</returns>
|
||||
public static short GetInt16(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToInt16(bytes.ToArray(), 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Byte"/>[] to an <see cref="Int32"/>.
|
||||
/// Converts the <see cref="byte"/>[] to an <see cref="int"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="Int32"/>.</returns>
|
||||
/// <returns>Returns an <see cref="int"/>.</returns>
|
||||
public static int GetInt32(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToInt32(bytes.ToArray(), 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Byte"/>[] to an <see cref="Int64"/>.
|
||||
/// Converts the <see cref="byte"/>[] to an <see cref="long"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="Int64"/>.</returns>
|
||||
/// <returns>Returns an <see cref="long"/>.</returns>
|
||||
public static long GetInt64(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToInt64(bytes.ToArray(), 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Byte"/>[] to a <see cref="UInt16"/>.
|
||||
/// Converts the <see cref="byte"/>[] to a <see cref="ushort"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="UInt16"/>.</returns>
|
||||
/// <returns>Returns an <see cref="ushort"/>.</returns>
|
||||
public static ushort GetUInt16(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToUInt16(bytes.ToArray(), 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Byte"/>[] to an <see cref="UInt32"/>.
|
||||
/// Converts the <see cref="byte"/>[] to an <see cref="uint"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="UInt32"/>.</returns>
|
||||
/// <returns>Returns an <see cref="uint"/>.</returns>
|
||||
public static uint GetUInt32(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToUInt32(bytes.ToArray(), 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Byte"/>[] to an <see cref="UInt64"/>.
|
||||
/// Converts the <see cref="byte"/>[] to an <see cref="ulong"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="UInt64"/>.</returns>
|
||||
/// <returns>Returns an <see cref="ulong"/>.</returns>
|
||||
public static ulong GetUInt64(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToUInt64(bytes.ToArray(), 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="String"/> representing the value the <see cref="Byte"/>[] with
|
||||
/// Gets a <see cref="string"/> representing the value the <see cref="byte"/>[] with
|
||||
/// <see cref="Encoding.UTF8"/> encoding.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns a <see cref="String"/>.</returns>
|
||||
/// <returns>Returns a <see cref="string"/>.</returns>
|
||||
public static string GetString(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return bytes.GetString(Encoding.UTF8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="String"/> representing the value the <see cref="Byte"/>[] with the provided encoding.
|
||||
/// Gets a <see cref="string"/> representing the value the <see cref="byte"/>[] with the provided encoding.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <param name="encoding">The encoding to use.</param>
|
||||
/// <returns>Returns a <see cref="String"/>.</returns>
|
||||
/// <returns>Returns a <see cref="string"/>.</returns>
|
||||
public static string GetString(this IEnumerable<byte> bytes, Encoding encoding)
|
||||
{
|
||||
IEnumerable<byte> enumerable = bytes as byte[] ?? bytes.ToArray();
|
||||
|
@ -6,7 +6,7 @@
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Char"/>.
|
||||
/// Extension methods for <see cref="char"/>.
|
||||
/// </summary>
|
||||
public static class CharExtensions
|
||||
{
|
||||
@ -15,7 +15,7 @@
|
||||
/// </summary>
|
||||
/// <param name="chars">The character set.</param>
|
||||
/// <param name="length">The length of the string to generate.</param>
|
||||
/// <returns>Returns a <see cref="String"/> containing <paramref name="length"/> characters.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> containing <paramref name="length"/> characters.</returns>
|
||||
public static string Random(this char[] chars, int length)
|
||||
{
|
||||
return chars.Random(length, new Random());
|
||||
@ -27,7 +27,7 @@
|
||||
/// <param name="chars">The character set.</param>
|
||||
/// <param name="length">The length of the string to generate.</param>
|
||||
/// <param name="random">The <see cref="System.Random"/> instance.</param>
|
||||
/// <returns>Returns a <see cref="String"/> containing <paramref name="length"/> characters.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> containing <paramref name="length"/> characters.</returns>
|
||||
public static string Random(this char[] chars, int length, Random random)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(length);
|
||||
@ -44,7 +44,7 @@
|
||||
/// </summary>
|
||||
/// <param name="chars">The character set.</param>
|
||||
/// <param name="length">The length of the string to generate.</param>
|
||||
/// <returns>Returns a <see cref="String"/> containing <paramref name="length"/> characters.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> containing <paramref name="length"/> characters.</returns>
|
||||
public static string Random(this IEnumerable<char> chars, int length)
|
||||
{
|
||||
return chars.Random(length, new Random());
|
||||
@ -56,7 +56,7 @@
|
||||
/// <param name="chars">The character set.</param>
|
||||
/// <param name="length">The length of the string to generate.</param>
|
||||
/// <param name="random">The <see cref="System.Random"/> instance.</param>
|
||||
/// <returns>Returns a <see cref="String"/> containing <paramref name="length"/> characters.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> containing <paramref name="length"/> characters.</returns>
|
||||
public static string Random(this IEnumerable<char> chars, int length, Random random)
|
||||
{
|
||||
return chars.ToArray().Random(length, random);
|
||||
@ -67,7 +67,7 @@
|
||||
/// </summary>
|
||||
/// <param name="c">The character to repeat.</param>
|
||||
/// <param name="count">The repeat count.</param>
|
||||
/// <returns>Returns a <see cref="String"/> whose value is <paramref name="c"/> repeated
|
||||
/// <returns>Returns a <see cref="string"/> whose value is <paramref name="c"/> repeated
|
||||
/// <paramref name="count"/> times.</returns>
|
||||
public static string Repeat(this char c, int count)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
/// <typeparam name="T1">The key type.</typeparam>
|
||||
/// <typeparam name="T2">The value type.</typeparam>
|
||||
/// <param name="dictionary">The dictionary.</param>
|
||||
/// <returns>Returns a <see cref="String"/> representing the dictionary as a key=value; set.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> representing the dictionary as a key=value; set.</returns>
|
||||
public static string ToConnectionString<T1, T2>(this IReadOnlyDictionary<T1, T2> dictionary)
|
||||
{
|
||||
static string SanitizeValue<T>(T value)
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
IEnumerable<string> strings =
|
||||
dictionary.Select(o => $"{o.Key}={SanitizeValue(o.Value)}");
|
||||
return String.Join(";", strings);
|
||||
return string.Join(";", strings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -40,7 +40,7 @@
|
||||
/// <typeparam name="T1">The key type.</typeparam>
|
||||
/// <typeparam name="T2">The value type.</typeparam>
|
||||
/// <param name="dictionary">The dictionary.</param>
|
||||
/// <returns>Returns a <see cref="String"/> representing the dictionary as a key=value; set.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> representing the dictionary as a key=value; set.</returns>
|
||||
public static string ToConnectionString<T1, T2>(this IDictionary<T1, T2> dictionary)
|
||||
{
|
||||
return ((IReadOnlyDictionary<T1, T2>) dictionary).ToConnectionString();
|
||||
@ -52,7 +52,7 @@
|
||||
/// <typeparam name="T1">The key type.</typeparam>
|
||||
/// <typeparam name="T2">The value type.</typeparam>
|
||||
/// <param name="dictionary">The dictionary.</param>
|
||||
/// <returns>Returns a <see cref="String"/> representing the dictionary as a key=value; set.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> representing the dictionary as a key=value; set.</returns>
|
||||
public static string ToConnectionString<T1, T2>(this Dictionary<T1, T2> dictionary)
|
||||
{
|
||||
return ((IReadOnlyDictionary<T1, T2>) dictionary).ToConnectionString();
|
||||
@ -64,7 +64,7 @@
|
||||
/// <typeparam name="T1">The key type.</typeparam>
|
||||
/// <typeparam name="T2">The value type.</typeparam>
|
||||
/// <param name="dictionary">The dictionary.</param>
|
||||
/// <returns>Returns a <see cref="String"/> representing the dictionary as a key=value& set.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> representing the dictionary as a key=value& set.</returns>
|
||||
public static string ToGetParameters<T1, T2>(this IReadOnlyDictionary<T1, T2> dictionary)
|
||||
{
|
||||
static string Sanitize(KeyValuePair<T1, T2> kvp)
|
||||
@ -74,7 +74,7 @@
|
||||
return $"{key}={value}";
|
||||
}
|
||||
|
||||
return String.Join("&", dictionary.Select(Sanitize));
|
||||
return string.Join("&", dictionary.Select(Sanitize));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -83,7 +83,7 @@
|
||||
/// <typeparam name="T1">The key type.</typeparam>
|
||||
/// <typeparam name="T2">The value type.</typeparam>
|
||||
/// <param name="dictionary">The dictionary.</param>
|
||||
/// <returns>Returns a <see cref="String"/> representing the dictionary as a key=value& set.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> representing the dictionary as a key=value& set.</returns>
|
||||
public static string ToGetParameters<T1, T2>(this IDictionary<T1, T2> dictionary)
|
||||
{
|
||||
return ((IReadOnlyDictionary<T1, T2>) dictionary).ToGetParameters();
|
||||
@ -95,7 +95,7 @@
|
||||
/// <typeparam name="T1">The key type.</typeparam>
|
||||
/// <typeparam name="T2">The value type.</typeparam>
|
||||
/// <param name="dictionary">The dictionary.</param>
|
||||
/// <returns>Returns a <see cref="String"/> representing the dictionary as a key=value& set.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> representing the dictionary as a key=value& set.</returns>
|
||||
public static string ToGetParameters<T1, T2>(this Dictionary<T1, T2> dictionary)
|
||||
{
|
||||
return ((IReadOnlyDictionary<T1, T2>) dictionary).ToGetParameters();
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Double"/>.
|
||||
/// Extension methods for <see cref="double"/>.
|
||||
/// </summary>
|
||||
public static class DoubleExtensions
|
||||
{
|
||||
@ -32,28 +32,28 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Double"/> to a <see cref="Byte"/>[].
|
||||
/// Converts the <see cref="double"/> to a <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this double number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Double"/> is even.
|
||||
/// Determines if the <see cref="double"/> is even.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
public static bool IsEven(this double number)
|
||||
{
|
||||
return Math.Abs(number % 2.0) < Double.Epsilon;
|
||||
return Math.Abs(number % 2.0) < double.Epsilon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Double"/> is odd.
|
||||
/// Determines if the <see cref="double"/> is odd.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
|
@ -12,7 +12,7 @@
|
||||
/// Gets the endpoint hostname.
|
||||
/// </summary>
|
||||
/// <param name="endPoint">The endpoint whose hostname to get.</param>
|
||||
/// <returns>Returns a <see cref="String"/> representing the hostname, which may be an IP or a DNS, or empty
|
||||
/// <returns>Returns a <see cref="string"/> representing the hostname, which may be an IP or a DNS, or empty
|
||||
/// string on failure.</returns>
|
||||
public static string GetHost(this EndPoint endPoint)
|
||||
{
|
||||
@ -20,7 +20,7 @@
|
||||
{
|
||||
IPEndPoint ip => ip.Address.ToString(),
|
||||
DnsEndPoint dns => dns.Host,
|
||||
_ => String.Empty
|
||||
_ => string.Empty
|
||||
};
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
/// Gets the endpoint port.
|
||||
/// </summary>
|
||||
/// <param name="endPoint">The endpoint whose port to get.</param>
|
||||
/// <returns>Returns an <see cref="Int32"/> representing the port, or 0 on failure.</returns>
|
||||
/// <returns>Returns an <see cref="int"/> representing the port, or 0 on failure.</returns>
|
||||
public static int GetPort(this EndPoint endPoint)
|
||||
{
|
||||
return endPoint switch
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Int16"/>.
|
||||
/// Extension methods for <see cref="short"/>.
|
||||
/// </summary>
|
||||
public static class Int16Extensions
|
||||
{
|
||||
@ -146,7 +146,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Int16"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||
/// Converts the <see cref="short"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||
/// </summary>
|
||||
/// <param name="timestamp">The timestamp.</param>
|
||||
/// <param name="isMillis">Optional. Whether or not the input value should be treated as milliseconds. Defaults
|
||||
@ -159,27 +159,27 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="UInt16"/> to a <see cref="Byte"/>[].
|
||||
/// Converts the <see cref="ushort"/> to a <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this ushort number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Int16"/> to a <see cref="Byte"/>[].
|
||||
/// Converts the <see cref="short"/> to a <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this short number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int16"/> is even.
|
||||
/// Determines if the <see cref="short"/> is even.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
@ -190,7 +190,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="UInt16"/> is even.
|
||||
/// Determines if the <see cref="ushort"/> is even.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
@ -201,7 +201,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int16"/> is odd.
|
||||
/// Determines if the <see cref="short"/> is odd.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
@ -212,7 +212,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="UInt16"/> is odd.
|
||||
/// Determines if the <see cref="ushort"/> is odd.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
@ -223,7 +223,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int16"/> is a prime number.
|
||||
/// Determines if the <see cref="short"/> is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||
@ -234,7 +234,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int16"/> is a prime number.
|
||||
/// Determines if the <see cref="short"/> is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Int32"/>.
|
||||
/// Extension methods for <see cref="int"/>.
|
||||
/// </summary>
|
||||
public static class Int32Extensions
|
||||
{
|
||||
@ -346,7 +346,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Int32"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||
/// Converts the <see cref="int"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||
/// </summary>
|
||||
/// <param name="timestamp">The timestamp.</param>
|
||||
/// <param name="isMillis">Optional. Whether or not the input value should be treated as milliseconds. Defaults
|
||||
@ -359,27 +359,27 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="UInt32"/> to a <see cref="Byte"/>[].
|
||||
/// Converts the <see cref="uint"/> to a <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this uint number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Int32"/> to a <see cref="Byte"/>[].
|
||||
/// Converts the <see cref="int"/> to a <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this int number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int32"/> is even.
|
||||
/// Determines if the <see cref="int"/> is even.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
@ -390,7 +390,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="UInt32"/> is even.
|
||||
/// Determines if the <see cref="uint"/> is even.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
@ -401,7 +401,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int32"/> is odd.
|
||||
/// Determines if the <see cref="int"/> is odd.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
@ -412,7 +412,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="UInt32"/> is odd.
|
||||
/// Determines if the <see cref="uint"/> is odd.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
@ -423,7 +423,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int32"/> is a prime number.
|
||||
/// Determines if the <see cref="int"/> is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Int64"/>.
|
||||
/// Extension methods for <see cref="long"/>.
|
||||
/// </summary>
|
||||
public static class Int64Extensions
|
||||
{
|
||||
@ -137,7 +137,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Int64"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||
/// Converts the <see cref="long"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||
/// </summary>
|
||||
/// <param name="timestamp">The timestamp.</param>
|
||||
/// <param name="isMillis">Optional. Whether or not the input value should be treated as milliseconds. Defaults
|
||||
@ -154,49 +154,49 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="UInt64"/> to a <see cref="Byte"/>[].
|
||||
/// Converts the <see cref="ulong"/> to a <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this ulong number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Int64"/> to a <see cref="Byte"/>[].
|
||||
/// Converts the <see cref="long"/> to a <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this long number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int64"/> is even.
|
||||
/// Determines if the <see cref="long"/> is even.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
public static bool IsEven(this long number)
|
||||
{
|
||||
return Math.Abs(number % 2.0) < Double.Epsilon;
|
||||
return Math.Abs(number % 2.0) < double.Epsilon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="UInt64"/> is even.
|
||||
/// Determines if the <see cref="ulong"/> is even.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
public static bool IsEven(this ulong number)
|
||||
{
|
||||
return Math.Abs(number % 2.0) < Double.Epsilon;
|
||||
return Math.Abs(number % 2.0) < double.Epsilon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int64"/> is odd.
|
||||
/// Determines if the <see cref="long"/> is odd.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
@ -207,7 +207,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="UInt64"/> is odd.
|
||||
/// Determines if the <see cref="ulong"/> is odd.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
@ -218,7 +218,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Int64"/> is a prime number.
|
||||
/// Determines if the <see cref="long"/> is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||
@ -253,7 +253,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="UInt64"/> is a prime number.
|
||||
/// Determines if the <see cref="ulong"/> is a prime number.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Single"/>.
|
||||
/// Extension methods for <see cref="float"/>.
|
||||
/// </summary>
|
||||
public static class SingleExtensions
|
||||
{
|
||||
@ -32,17 +32,17 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Single"/> to a <see cref="Byte"/>[].
|
||||
/// Converts the <see cref="float"/> to a <see cref="byte"/>[].
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this float number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Single"/> is even.
|
||||
/// Determines if the <see cref="float"/> is even.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
@ -53,7 +53,7 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the <see cref="Single"/> is odd.
|
||||
/// Determines if the <see cref="float"/> is odd.
|
||||
/// </summary>
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
/// </summary>
|
||||
/// <typeparam name="T">A <see cref="HashAlgorithm"/> derived type.</typeparam>
|
||||
/// <param name="stream">The stream whose hash is to be computed.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/> array representing the hash of the stream.</returns>
|
||||
/// <returns>Returns a <see cref="byte"/> array representing the hash of the stream.</returns>
|
||||
public static byte[] GetHash<T>(this Stream stream) where T : HashAlgorithm
|
||||
{
|
||||
MethodInfo create = typeof(T).GetMethod("Create", Array.Empty<Type>());
|
||||
|
@ -8,7 +8,7 @@
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="String"/>.
|
||||
/// Extension methods for <see cref="string"/>.
|
||||
/// </summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
@ -33,23 +33,23 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a <see cref="String"/> into an <see cref="Enum"/>.
|
||||
/// Parses a <see cref="string"/> into an <see cref="Enum"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the <see cref="Enum"/>.</typeparam>
|
||||
/// <param name="value">The <see cref="String"/> value to parse</param>
|
||||
/// <returns>The <see cref="Enum"/> value corresponding to the <see cref="String"/>.</returns>
|
||||
/// <param name="value">The <see cref="string"/> value to parse</param>
|
||||
/// <returns>The <see cref="Enum"/> value corresponding to the <see cref="string"/>.</returns>
|
||||
public static T EnumParse<T>(this string value)
|
||||
{
|
||||
return value.EnumParse<T>(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a <see cref="String"/> into an <see cref="Enum"/>.
|
||||
/// Parses a <see cref="string"/> into an <see cref="Enum"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the <see cref="Enum"/>.</typeparam>
|
||||
/// <param name="value">The <see cref="String"/> value to parse</param>
|
||||
/// <param name="value">The <see cref="string"/> value to parse</param>
|
||||
/// <param name="ignoreCase">Whether or not to ignore casing.</param>
|
||||
/// <returns>The <see cref="Enum"/> value corresponding to the <see cref="String"/></returns>
|
||||
/// <returns>The <see cref="Enum"/> value corresponding to the <see cref="string"/></returns>
|
||||
public static T EnumParse<T>(this string value, bool ignoreCase)
|
||||
{
|
||||
if (value == null)
|
||||
@ -76,22 +76,22 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Byte"/>[] representing the value the <see cref="String"/> with
|
||||
/// Gets a <see cref="byte"/>[] representing the value the <see cref="string"/> with
|
||||
/// <see cref="Encoding.UTF8"/> encoding.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to convert.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this string str)
|
||||
{
|
||||
return str.GetBytes(Encoding.UTF8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Byte"/>[] representing the value the <see cref="String"/> with the provided encoding.
|
||||
/// Gets a <see cref="byte"/>[] representing the value the <see cref="string"/> with the provided encoding.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to convert.</param>
|
||||
/// <param name="encoding">The encoding to use.</param>
|
||||
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
public static byte[] GetBytes(this string str, Encoding encoding)
|
||||
{
|
||||
return encoding.GetBytes(str);
|
||||
@ -102,7 +102,7 @@
|
||||
/// </summary>
|
||||
/// <param name="str">The character set.</param>
|
||||
/// <param name="length">The length of the string to generate.</param>
|
||||
/// <returns>Returns a <see cref="String"/> containing <paramref name="length"/> characters.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> containing <paramref name="length"/> characters.</returns>
|
||||
public static string Random(this string str, int length)
|
||||
{
|
||||
return str.Random(length, new Random());
|
||||
@ -114,7 +114,7 @@
|
||||
/// <param name="str">The character set.</param>
|
||||
/// <param name="length">The length of the string to generate.</param>
|
||||
/// <param name="random">The <see cref="System.Random"/> instance.</param>
|
||||
/// <returns>Returns a <see cref="String"/> containing <paramref name="length"/> characters.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> containing <paramref name="length"/> characters.</returns>
|
||||
public static string Random(this string str, int length, Random random)
|
||||
{
|
||||
return str.ToCharArray().Random(length, random);
|
||||
@ -125,7 +125,7 @@
|
||||
/// </summary>
|
||||
/// <param name="str">The string to repeat.</param>
|
||||
/// <param name="count">The repeat count.</param>
|
||||
/// <returns>Returns a <see cref="String"/> whose value is <paramref name="str"/> repeated
|
||||
/// <returns>Returns a <see cref="string"/> whose value is <paramref name="str"/> repeated
|
||||
/// <paramref name="count"/> times.</returns>
|
||||
public static string Repeat(this string str, int count)
|
||||
{
|
||||
@ -143,7 +143,7 @@
|
||||
/// Shuffles the characters in the string.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to shuffle.</param>
|
||||
/// <returns>Returns a <see cref="String"/> containing the characters in <paramref name="str"/>, rearranged.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> containing the characters in <paramref name="str"/>, rearranged.</returns>
|
||||
public static string Shuffle(this string str)
|
||||
{
|
||||
return str.Shuffle(new Random());
|
||||
@ -154,18 +154,18 @@
|
||||
/// </summary>
|
||||
/// <param name="str">The string to shuffle.</param>
|
||||
/// <param name="random">The <see cref="System.Random"/> instance.</param>
|
||||
/// <returns>Returns a <see cref="String"/> containing the characters in <paramref name="str"/>, rearranged.</returns>
|
||||
/// <returns>Returns a <see cref="string"/> containing the characters in <paramref name="str"/>, rearranged.</returns>
|
||||
public static string Shuffle(this string str, Random random)
|
||||
{
|
||||
return new string(str.ToCharArray().Shuffle(random).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Splits the <see cref="String"/> into chunks that are no greater than <paramref name="chunkSize"/> in length.
|
||||
/// Splits the <see cref="string"/> into chunks that are no greater than <paramref name="chunkSize"/> in length.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to split.</param>
|
||||
/// <param name="chunkSize">The maximum length of each string in the returned result.</param>
|
||||
/// <returns>Returns an <see cref="IEnumerable{T}"/> containing <see cref="String"/> instances which are no
|
||||
/// <returns>Returns an <see cref="IEnumerable{T}"/> containing <see cref="string"/> instances which are no
|
||||
/// greater than <paramref name="chunkSize"/> in length.</returns>
|
||||
public static IEnumerable<string> Split(this string str, int chunkSize)
|
||||
{
|
||||
@ -176,13 +176,13 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="String"/> to a <see cref="SecureString"/>.
|
||||
/// Converts a <see cref="string"/> to a <see cref="SecureString"/>.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to convert.</param>
|
||||
/// <returns>Returns a <see cref="SecureString"/>.</returns>
|
||||
public static SecureString ToSecureString(this string str)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(str))
|
||||
if (string.IsNullOrWhiteSpace(str))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -197,14 +197,14 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="SecureString"/> to a <see cref="String"/>.
|
||||
/// Converts a <see cref="SecureString"/> to a <see cref="string"/>.
|
||||
/// </summary>
|
||||
/// <param name="str">The <see cref="SecureString"/> to convert.</param>
|
||||
/// <param name="extension">Whether or not to use this extension method.</param>
|
||||
/// <returns>Returns a <see cref="String"/>.</returns>
|
||||
/// <returns>Returns a <see cref="string"/>.</returns>
|
||||
public static string ToString(this SecureString str, bool extension)
|
||||
{
|
||||
return extension ? (new NetworkCredential(String.Empty, str).Password) : str.ToString();
|
||||
return extension ? (new NetworkCredential(string.Empty, str).Password) : str.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -27,32 +27,32 @@
|
||||
|
||||
if (match.Groups[1].Success)
|
||||
{
|
||||
weeks = Double.Parse(match.Groups[1].Value);
|
||||
weeks = double.Parse(match.Groups[1].Value);
|
||||
}
|
||||
|
||||
if (match.Groups[2].Success)
|
||||
{
|
||||
days = Double.Parse(match.Groups[2].Value);
|
||||
days = double.Parse(match.Groups[2].Value);
|
||||
}
|
||||
|
||||
if (match.Groups[3].Success)
|
||||
{
|
||||
hours = Double.Parse(match.Groups[3].Value);
|
||||
hours = double.Parse(match.Groups[3].Value);
|
||||
}
|
||||
|
||||
if (match.Groups[4].Success)
|
||||
{
|
||||
minutes = Double.Parse(match.Groups[4].Value);
|
||||
minutes = double.Parse(match.Groups[4].Value);
|
||||
}
|
||||
|
||||
if (match.Groups[5].Success)
|
||||
{
|
||||
seconds = Double.Parse(match.Groups[5].Value);
|
||||
seconds = double.Parse(match.Groups[5].Value);
|
||||
}
|
||||
|
||||
if (match.Groups[6].Success)
|
||||
{
|
||||
milliseconds = Double.Parse(match.Groups[6].Value);
|
||||
milliseconds = double.Parse(match.Groups[6].Value);
|
||||
}
|
||||
|
||||
Trace.WriteLine($"Input: {input}");
|
||||
|
Loading…
Reference in New Issue
Block a user