mirror of https://github.com/oliverbooth/X10D
(#14) Perform solution-wide code cleanup
This commit is contained in:
parent
b81cac03d6
commit
ac203dda1f
|
@ -60,13 +60,13 @@ namespace X10D
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// byte[] bytes = { byte.MinValue, 100, 200, byte.MaxValue };
|
/// byte[] bytes = { byte.MinValue, 100, 200, byte.MaxValue };
|
||||||
/// bool result;
|
/// bool result;
|
||||||
///
|
///
|
||||||
/// foreach (byte value in bytes)
|
/// foreach (byte value in bytes)
|
||||||
/// {
|
/// {
|
||||||
/// result = value.ToBoolean();
|
/// result = value.ToBoolean();
|
||||||
/// Console.WriteLine("{0, -5} --> {1}", value, result);
|
/// Console.WriteLine("{0, -5} --> {1}", value, result);
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// // The example displays the following output:
|
/// // The example displays the following output:
|
||||||
/// // 0 --> False
|
/// // 0 --> False
|
||||||
/// // 100 --> True
|
/// // 100 --> True
|
||||||
|
|
|
@ -18,8 +18,8 @@ namespace X10D
|
||||||
/// <param name="lower">The exclusive lower bound.</param>
|
/// <param name="lower">The exclusive lower bound.</param>
|
||||||
/// <param name="upper">The exclusive upper bound.</param>
|
/// <param name="upper">The exclusive upper bound.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see langword="true" /> if <paramref name="value" /> is between the <paramref name="lower"/> and
|
/// <see langword="true" /> if <paramref name="value" /> is between the <paramref name="lower" /> and
|
||||||
/// <paramref name="upper"/>
|
/// <paramref name="upper" />
|
||||||
/// -or-
|
/// -or-
|
||||||
/// <see langword="false" /> otherwise.
|
/// <see langword="false" /> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
@ -30,13 +30,13 @@ namespace X10D
|
||||||
///
|
///
|
||||||
/// int lower = 0;
|
/// int lower = 0;
|
||||||
/// int upper = 20;
|
/// int upper = 20;
|
||||||
///
|
///
|
||||||
/// Console.WriteLine($"{firstValue} between {lower} and {upper}?");
|
/// Console.WriteLine($"{firstValue} between {lower} and {upper}?");
|
||||||
/// Console.WriteLine(firstValue.Between(lower, upper));
|
/// Console.WriteLine(firstValue.Between(lower, upper));
|
||||||
///
|
///
|
||||||
/// Console.WriteLine($"{secondValue} between {lower} and {upper}?");
|
/// Console.WriteLine($"{secondValue} between {lower} and {upper}?");
|
||||||
/// Console.WriteLine(secondValue.Between(lower, upper));
|
/// Console.WriteLine(secondValue.Between(lower, upper));
|
||||||
///
|
///
|
||||||
/// // This will output the following:
|
/// // This will output the following:
|
||||||
/// // 42 between 0 and 20?
|
/// // 42 between 0 and 20?
|
||||||
/// // False
|
/// // False
|
||||||
|
@ -84,7 +84,7 @@ namespace X10D
|
||||||
/// int value = 42;
|
/// int value = 42;
|
||||||
/// int lower = 0;
|
/// int lower = 0;
|
||||||
/// int upper = 20;
|
/// int upper = 20;
|
||||||
///
|
///
|
||||||
/// int clamped = value.Clamp(lower, upper);
|
/// int clamped = value.Clamp(lower, upper);
|
||||||
/// // clamped will be 20
|
/// // clamped will be 20
|
||||||
/// </code>
|
/// </code>
|
||||||
|
@ -112,13 +112,13 @@ namespace X10D
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see langword="true" /> if <paramref name="value" /> is greater than <paramref name="other" />
|
/// <see langword="true" /> if <paramref name="value" /> is greater than <paramref name="other" />
|
||||||
/// -or-
|
/// -or-
|
||||||
/// <see langword="false"/> otherwise.
|
/// <see langword="false" /> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// int first = 5;
|
/// int first = 5;
|
||||||
/// int second = 10;
|
/// int second = 10;
|
||||||
///
|
///
|
||||||
/// bool result = first.GreaterThan(second);
|
/// bool result = first.GreaterThan(second);
|
||||||
/// // result will be False
|
/// // result will be False
|
||||||
/// </code>
|
/// </code>
|
||||||
|
@ -144,13 +144,13 @@ namespace X10D
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see langword="true" /> if <paramref name="value" /> is greater than or equal to <paramref name="other" />
|
/// <see langword="true" /> if <paramref name="value" /> is greater than or equal to <paramref name="other" />
|
||||||
/// -or-
|
/// -or-
|
||||||
/// <see langword="false"/> otherwise.
|
/// <see langword="false" /> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// int first = 5;
|
/// int first = 5;
|
||||||
/// int second = 10;
|
/// int second = 10;
|
||||||
///
|
///
|
||||||
/// bool result = first.GreaterThanOrEqualTo(second);
|
/// bool result = first.GreaterThanOrEqualTo(second);
|
||||||
/// // result will be False
|
/// // result will be False
|
||||||
/// </code>
|
/// </code>
|
||||||
|
@ -176,13 +176,13 @@ namespace X10D
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see langword="true" /> if <paramref name="value" /> is less than <paramref name="other" />
|
/// <see langword="true" /> if <paramref name="value" /> is less than <paramref name="other" />
|
||||||
/// -or-
|
/// -or-
|
||||||
/// <see langword="false"/> otherwise.
|
/// <see langword="false" /> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// int first = 5;
|
/// int first = 5;
|
||||||
/// int second = 10;
|
/// int second = 10;
|
||||||
///
|
///
|
||||||
/// bool result = first.LessThan(second);
|
/// bool result = first.LessThan(second);
|
||||||
/// // result will be True
|
/// // result will be True
|
||||||
/// </code>
|
/// </code>
|
||||||
|
@ -208,13 +208,13 @@ namespace X10D
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see langword="true" /> if <paramref name="value" /> is less than or equal to <paramref name="other" />
|
/// <see langword="true" /> if <paramref name="value" /> is less than or equal to <paramref name="other" />
|
||||||
/// -or-
|
/// -or-
|
||||||
/// <see langword="false"/> otherwise.
|
/// <see langword="false" /> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// int first = 5;
|
/// int first = 5;
|
||||||
/// int second = 10;
|
/// int second = 10;
|
||||||
///
|
///
|
||||||
/// bool result = first.LessThanOrEqualTo(second);
|
/// bool result = first.LessThanOrEqualTo(second);
|
||||||
/// // result will be True
|
/// // result will be True
|
||||||
/// </code>
|
/// </code>
|
||||||
|
@ -245,7 +245,7 @@ namespace X10D
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// int first = 5;
|
/// int first = 5;
|
||||||
/// int second = 10;
|
/// int second = 10;
|
||||||
///
|
///
|
||||||
/// int max = first.Max(second);
|
/// int max = first.Max(second);
|
||||||
/// // max will be 10
|
/// // max will be 10
|
||||||
/// </code>
|
/// </code>
|
||||||
|
@ -276,7 +276,7 @@ namespace X10D
|
||||||
/// <code lang="csharp">
|
/// <code lang="csharp">
|
||||||
/// int first = 5;
|
/// int first = 5;
|
||||||
/// int second = 10;
|
/// int second = 10;
|
||||||
///
|
///
|
||||||
/// int min = first.Min(second);
|
/// int min = first.Min(second);
|
||||||
/// // min will be 5
|
/// // min will be 5
|
||||||
/// </code>
|
/// </code>
|
||||||
|
|
|
@ -54,9 +54,6 @@ namespace X10D
|
||||||
return string.Join(";", list);
|
return string.Join(";", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <returns>A <see cref="string" /> representing the dictionary as a <c>key=value;</c> set.</returns>
|
|
||||||
///
|
|
||||||
///
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts an <see cref="IEnumerable{T}" /> of <see cref="KeyValuePair{TKey, TValue}" /> to a HTTP GET parameter
|
/// Converts an <see cref="IEnumerable{T}" /> of <see cref="KeyValuePair{TKey, TValue}" /> to a HTTP GET parameter
|
||||||
/// string.
|
/// string.
|
||||||
|
@ -64,7 +61,7 @@ namespace X10D
|
||||||
/// <typeparam name="TKey">The key type.</typeparam>
|
/// <typeparam name="TKey">The key type.</typeparam>
|
||||||
/// <typeparam name="TValue">The value type.</typeparam>
|
/// <typeparam name="TValue">The value type.</typeparam>
|
||||||
/// <param name="value">The source dictionary.</param>
|
/// <param name="value">The source 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<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> value)
|
public static string ToGetParameters<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> value)
|
||||||
{
|
{
|
||||||
if (value is null)
|
if (value is null)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace X10D
|
namespace X10D
|
||||||
|
@ -124,7 +124,7 @@ namespace X10D
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The value to round.</param>
|
/// <param name="value">The value to round.</param>
|
||||||
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
||||||
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest"/>.</returns>
|
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
||||||
public static double Round(this double value, double nearest)
|
public static double Round(this double value, double nearest)
|
||||||
{
|
{
|
||||||
return Math.Round(value / nearest) * nearest;
|
return Math.Round(value / nearest) * nearest;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace X10D
|
namespace X10D
|
||||||
|
@ -29,7 +29,7 @@ namespace X10D
|
||||||
/// <param name="chunkSize">The maximum length of the nested collection.</param>
|
/// <param name="chunkSize">The maximum length of the nested collection.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// An <see cref="IEnumerable{T}" /> containing an <see cref="IEnumerable{T}" /> of <typeparamref name="T" />
|
/// An <see cref="IEnumerable{T}" /> containing an <see cref="IEnumerable{T}" /> of <typeparamref name="T" />
|
||||||
/// whose lengths are no greater than <paramref name="chunkSize" />.
|
/// whose lengths are no greater than <paramref name="chunkSize" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IEnumerable<IEnumerable<T>> Split<T>(this IEnumerable<T> value, int chunkSize)
|
public static IEnumerable<IEnumerable<T>> Split<T>(this IEnumerable<T> value, int chunkSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace X10D
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
return DateTimeOffset.FromUnixTimeMilliseconds(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a
|
/// Converts a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a
|
||||||
/// <see cref="DateTimeOffset" /> value.
|
/// <see cref="DateTimeOffset" /> value.
|
||||||
|
@ -35,7 +35,7 @@ namespace X10D
|
||||||
{
|
{
|
||||||
return DateTimeOffset.FromUnixTimeSeconds(value);
|
return DateTimeOffset.FromUnixTimeSeconds(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the current 64-bit signed integer value as an array of bytes.
|
/// Returns the current 64-bit signed integer value as an array of bytes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -45,6 +45,7 @@ namespace X10D
|
||||||
{
|
{
|
||||||
return BitConverter.GetBytes(value);
|
return BitConverter.GetBytes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
/// Returns a value indicating whether the current value is evenly divisible by 2.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
@ -58,7 +58,7 @@ namespace X10D
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a random color
|
/// Returns a random color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="random"></param>
|
/// <param name="random"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
@ -212,7 +212,7 @@ namespace X10D
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A 64-bit signed integer that is greater than or equal to 0, and less than <paramref name="maxValue" />; that is,
|
/// A 64-bit signed integer that is greater than or equal to 0, and less than <paramref name="maxValue" />; that is,
|
||||||
/// the range of return values ordinarily includes 0 but not <paramref name="maxValue" />. However, if
|
/// the range of return values ordinarily includes 0 but not <paramref name="maxValue" />. However, if
|
||||||
/// <paramref name="maxValue" /> equals 0, <paramref name="maxValue"/> is returned.
|
/// <paramref name="maxValue" /> equals 0, <paramref name="maxValue" /> is returned.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <remarks><paramref name="maxValue" /> must be greater than or equal to 0.</remarks>
|
/// <remarks><paramref name="maxValue" /> must be greater than or equal to 0.</remarks>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="random" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="random" /> is <see langword="null" />.</exception>
|
||||||
|
|
|
@ -77,8 +77,9 @@ namespace X10D
|
||||||
/// -or-
|
/// -or-
|
||||||
/// <paramref name="selector" /> is <see langword="null" />.
|
/// <paramref name="selector" /> is <see langword="null" />.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public static TReturn? SelectFromCustomAttribute<TAttribute, TReturn>(this MemberInfo member,
|
public static TReturn? SelectFromCustomAttribute<TAttribute, TReturn>(
|
||||||
Func<TAttribute, TReturn> selector)
|
this MemberInfo member,
|
||||||
|
Func<TAttribute, TReturn> selector)
|
||||||
where TAttribute : Attribute
|
where TAttribute : Attribute
|
||||||
{
|
{
|
||||||
if (member is null)
|
if (member is null)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace X10D
|
namespace X10D
|
||||||
|
@ -124,7 +124,7 @@ namespace X10D
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The value to round.</param>
|
/// <param name="value">The value to round.</param>
|
||||||
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
/// <param name="nearest">The nearest multiple to which <paramref name="value" /> should be rounded.</param>
|
||||||
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest"/>.</returns>
|
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
||||||
public static float Round(this float value, float nearest)
|
public static float Round(this float value, float nearest)
|
||||||
{
|
{
|
||||||
return (float)((double)value).Round(nearest);
|
return (float)((double)value).Round(nearest);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
#if NET5_0
|
#if NET5_0
|
||||||
using System.Buffers.Binary;
|
using System.Buffers.Binary;
|
||||||
#endif
|
#endif
|
||||||
using System.IO;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
|
|
||||||
namespace X10D
|
namespace X10D
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -134,14 +134,14 @@ namespace X10D
|
||||||
throw new ArgumentException(Resource.EnumParseEmptyStringException, nameof(value));
|
throw new ArgumentException(Resource.EnumParseEmptyStringException, nameof(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
var t = typeof(T);
|
var type = typeof(T);
|
||||||
|
|
||||||
if (!t.IsEnum)
|
if (!type.IsEnum)
|
||||||
{
|
{
|
||||||
throw new ArgumentException(Resource.EnumParseNotEnumException);
|
throw new ArgumentException(Resource.EnumParseNotEnumException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (T)Enum.Parse(t, value, ignoreCase);
|
return (T)Enum.Parse(type, value, ignoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -45,8 +45,8 @@ namespace X10D
|
||||||
{
|
{
|
||||||
parsedResult = 0;
|
parsedResult = 0;
|
||||||
|
|
||||||
return match.Groups[@group].Success
|
return match.Groups[group].Success
|
||||||
&& double.TryParse(match.Groups[@group].Value, NumberStyles.Number, provider, out parsedResult);
|
&& double.TryParse(match.Groups[group].Value, NumberStyles.Number, provider, out parsedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TryParseAt(1, out var years))
|
if (!TryParseAt(1, out var years))
|
||||||
|
|
Loading…
Reference in New Issue