Skip to content

Commit

Permalink
Merge pull request #45 from Afischbacher/develop
Browse files Browse the repository at this point in the history
v3.1.0
  • Loading branch information
Afischbacher authored Jan 5, 2024
2 parents ed48620 + 08489ba commit d543a3f
Show file tree
Hide file tree
Showing 108 changed files with 193,195 additions and 187,918 deletions.
15 changes: 7 additions & 8 deletions Nhl.Api.Common/Exceptions/InvalidPlayerPositionException.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System;

namespace Nhl.Api.Common.Exceptions
namespace Nhl.Api.Common.Exceptions;

/// <summary>
/// An exception for when a request is made to the Nhl.Api and the player/goalie position is invalid
/// </summary>
public class InvalidPlayerPositionException : Exception
{
/// <summary>
/// An exception for when a request is made to the Nhl.Api and the player/goalie position is invalid
/// </summary>
public class InvalidPlayerPositionException : Exception
public InvalidPlayerPositionException(string message) : base(message)
{
/// <summary>
/// An exception for when a request is made to the Nhl.Api and the player/goalie position is invalid
/// </summary>
public InvalidPlayerPositionException(string message) : base(message)
{

}
}
}
15 changes: 7 additions & 8 deletions Nhl.Api.Common/Exceptions/InvalidSeasonException.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System;

namespace Nhl.Api.Common.Exceptions
namespace Nhl.Api.Common.Exceptions;

/// <summary>
/// An exception when the season year entered is not a valid NHL season
/// </summary>
public class InvalidSeasonException : Exception
{
/// <summary>
/// An exception when the season year entered is not a valid NHL season
/// </summary>
public class InvalidSeasonException : Exception
public InvalidSeasonException(string message) : base(message)
{
/// <summary>
/// An exception when the season year entered is not a valid NHL season
/// </summary>
public InvalidSeasonException(string message) : base(message)
{

}
}
}
15 changes: 7 additions & 8 deletions Nhl.Api.Common/Exceptions/NhlApiRequestException.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System;

namespace Nhl.Api.Common.Exceptions
namespace Nhl.Api.Common.Exceptions;

/// <summary>
/// An exception for a failed Nhl.Api HTTP request
/// </summary>
public class NhlApiRequestException : Exception
{
/// <summary>
/// An exception for a failed Nhl.Api HTTP request
/// </summary>
public class NhlApiRequestException : Exception
public NhlApiRequestException(string message) : base(message)
{
/// <summary>
/// An exception for a failed Nhl.Api HTTP request
/// </summary>
public NhlApiRequestException(string message) : base(message)
{

}
}
}
35 changes: 17 additions & 18 deletions Nhl.Api.Common/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
using System.Reflection;
using System.Runtime.Serialization;

namespace Nhl.Api.Common.Extensions
namespace Nhl.Api.Common.Extensions;

/// <summary>
/// An enumerations extension class for the Nhl.Api
/// </summary>
public static class EnumExtensions
{
/// <summary>
/// An enumerations extension class for the Nhl.Api
/// Retrieves the <see cref="EnumMemberAttribute"/> value for a specific enumeration
/// </summary>
public static class EnumExtensions
/// <typeparam name="T">The enumeration type</typeparam>
/// <param name="value">The value of the enumerations</param>
/// <returns>The string value of the enumeration based on the attribute <see cref="EnumMemberAttribute"/></returns>
public static string GetEnumMemberValue<T>(this T value) where T : Enum
{
/// <summary>
/// Retrieves the <see cref="EnumMemberAttribute"/> value for a specific enumeration
/// </summary>
/// <typeparam name="T">The enumeration type</typeparam>
/// <param name="value">The value of the enumerations</param>
/// <returns>The string value of the enumeration based on the attribute <see cref="EnumMemberAttribute"/></returns>
public static string GetEnumMemberValue<T>(this T value) where T : Enum
{
return typeof(T)
.GetTypeInfo()
.DeclaredMembers
.SingleOrDefault(x => x.Name == value.ToString())
?.GetCustomAttribute<EnumMemberAttribute>(false)
?.Value ?? null;
}
return typeof(T)
.GetTypeInfo()
.DeclaredMembers
.SingleOrDefault(x => x.Name == value.ToString())
?.GetCustomAttribute<EnumMemberAttribute>(false)
?.Value ?? null;
}
}
35 changes: 17 additions & 18 deletions Nhl.Api.Common/Extensions/LinqExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
using System;
using System.Collections.Generic;

namespace Nhl.Api.Common.Extensions
namespace Nhl.Api.Common.Extensions;

/// <summary>
/// A collection of LINQ extensions for the Nhl.Api
/// </summary>
public static class LinqExtensions
{
/// <summary>
/// A collection of LINQ extensions for the Nhl.Api
/// An extension method for finding elements in an array distinctly by a specific key or set of keys
/// </summary>
public static class LinqExtensions
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="TKey"></typeparam>
/// <param name="source"></param>
/// <param name="keySelector"></param>
/// <returns></returns>
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
/// <summary>
/// An extension method for finding elements in an array distinctly by a specific key or set of keys
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="TKey"></typeparam>
/// <param name="source"></param>
/// <param name="keySelector"></param>
/// <returns></returns>
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
HashSet<TKey> seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
{
HashSet<TKey> seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
if (seenKeys.Add(keySelector(element)))
{
if (seenKeys.Add(keySelector(element)))
{
yield return element;
}
yield return element;
}
}
}
Expand Down
29 changes: 14 additions & 15 deletions Nhl.Api.Common/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
using System;

namespace Nhl.Api.Common.Extensions
namespace Nhl.Api.Common.Extensions;

/// <summary>
/// A simple library for String extensions for the Nhl.Api
/// </summary>
public static class StringExtensions
{
/// <summary>
/// A simple library for String extensions for the Nhl.Api
/// Converts a string to a camel case formatted string
/// </summary>
public static class StringExtensions
/// <param name="value">The string value needed to be converted to camel case</param>
/// <returns>A camel cased string, Example: aCamelCasedString</returns>
public static string ToCamelCase(this string value)
{
/// <summary>
/// Converts a string to a camel case formatted string
/// </summary>
/// <param name="value">The string value needed to be converted to camel case</param>
/// <returns>A camel cased string, Example: aCamelCasedString</returns>
public static string ToCamelCase(this string value)
if (string.IsNullOrWhiteSpace(value))
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentNullException(nameof(value));
}

return char.ToLowerInvariant(value[0]) + value.Substring(1);
throw new ArgumentNullException(nameof(value));
}

return char.ToLowerInvariant(value[0]) + value.Substring(1);
}
}
Loading

0 comments on commit d543a3f

Please sign in to comment.