Skip to content

Commit

Permalink
Merge pull request #54 from Afischbacher/develop
Browse files Browse the repository at this point in the history
v3.4.1
  • Loading branch information
Afischbacher committed Mar 28, 2024
2 parents f160400 + 7bfab26 commit 7067ff7
Show file tree
Hide file tree
Showing 99 changed files with 1,966 additions and 1,109 deletions.
444 changes: 444 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Nhl.Api.Common/Exceptions/InvalidPlayerPositionException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System;

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>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Common/Exceptions/InvalidSeasonException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;

namespace Nhl.Api.Common.Exceptions;

/// <summary>
/// An exception when the season year entered is not a valid NHL season
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Common/Exceptions/NhlApiRequestException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;

namespace Nhl.Api.Common.Exceptions;

/// <summary>
/// An exception for a failed Nhl.Api HTTP request
/// </summary>
Expand Down
6 changes: 1 addition & 5 deletions Nhl.Api.Common/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Runtime.Serialization;

namespace Nhl.Api.Common.Extensions;

/// <summary>
/// An enumerations extension class for the Nhl.Api
/// </summary>
Expand All @@ -16,13 +15,10 @@ 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
{
return typeof(T)
public static string GetEnumMemberValue<T>(this T value) where T : Enum => typeof(T)

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 18 in Nhl.Api.Common/Extensions/EnumExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.
.GetTypeInfo()
.DeclaredMembers
.SingleOrDefault(x => x.Name == value.ToString())
?.GetCustomAttribute<EnumMemberAttribute>(false)
?.Value ?? null;
}
}
3 changes: 1 addition & 2 deletions Nhl.Api.Common/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;

namespace Nhl.Api.Common.Extensions;

/// <summary>
/// A helper class for string extensions
/// </summary>
Expand Down
741 changes: 494 additions & 247 deletions Nhl.Api.Common/Helpers/CountryCodeHelper.cs

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Nhl.Api.Common/Helpers/TimeStampHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System;
using System.Globalization;

namespace Nhl.Api.Common.Helpers;

/// <summary>
/// A helper class to parse the meta data time stamp in Nhl.Api responses
/// </summary>
Expand Down Expand Up @@ -40,7 +40,7 @@ public class TimeStampHelper
var minute = datetime[1].Substring(2, 2);
var second = datetime[1].Substring(4, 2);

return DateTimeOffset.Parse($"{year}-{month}-{day}T{hour}:{minute}:{second}") as DateTimeOffset? ?? null;
return DateTimeOffset.Parse($"{year}-{month}-{day}T{hour}:{minute}:{second}", CultureInfo.InvariantCulture) as DateTimeOffset? ?? null;
}
catch
{
Expand All @@ -49,19 +49,19 @@ public class TimeStampHelper
}

/// <summary>
/// Parses a <see cref="DateTimeOffset"/> to a meta data timestamp for the Nhl.Api
/// Parses a <see cref="DateTimeOffset"/> to a meta data time-stamp for the Nhl.Api
/// </summary>
/// <param name="dateTimeOffset">The timestamp, Example: <see cref="DateTimeOffset.Now"/> </param>
/// <returns>A parsed game meta data timestamp in UTC, Exampe: 20231105_201423</returns>
/// <param name="dateTimeOffset">The time-stamp, Example: <see cref="DateTimeOffset.Now"/> </param>
/// <returns>A parsed game meta data time-stamp in UTC, Example: 20231105_201423</returns>
public static string ParseDateTimeOffsetFromTimeStamp(DateTimeOffset dateTimeOffset)
{
var year = dateTimeOffset.Year;
var day = dateTimeOffset.Day < 10 ? $"0{dateTimeOffset.Day}" : dateTimeOffset.Day.ToString();
var month = dateTimeOffset.Month < 10 ? $"0{dateTimeOffset.Month}" : dateTimeOffset.Month.ToString();
var day = dateTimeOffset.Day < 10 ? $"0{dateTimeOffset.Day}" : dateTimeOffset.Day.ToString(CultureInfo.InvariantCulture);
var month = dateTimeOffset.Month < 10 ? $"0{dateTimeOffset.Month}" : dateTimeOffset.Month.ToString(CultureInfo.InvariantCulture);

var hour = dateTimeOffset.Hour < 10 ? $"0{dateTimeOffset.Hour}" : dateTimeOffset.Hour.ToString();
var minute = dateTimeOffset.Minute < 10 ? $"0{dateTimeOffset.Minute}" : dateTimeOffset.Minute.ToString();
var second = dateTimeOffset.Second < 10 ? $"0{dateTimeOffset.Second}" : dateTimeOffset.Second.ToString();
var hour = dateTimeOffset.Hour < 10 ? $"0{dateTimeOffset.Hour}" : dateTimeOffset.Hour.ToString(CultureInfo.InvariantCulture);
var minute = dateTimeOffset.Minute < 10 ? $"0{dateTimeOffset.Minute}" : dateTimeOffset.Minute.ToString(CultureInfo.InvariantCulture);
var second = dateTimeOffset.Second < 10 ? $"0{dateTimeOffset.Second}" : dateTimeOffset.Second.ToString(CultureInfo.InvariantCulture);

return $"{year}{month}{day}_{hour}{minute}{second}";

Expand Down
6 changes: 2 additions & 4 deletions Nhl.Api.Common/Http/NhlApiHttpClient.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using System;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

namespace Nhl.Api.Common.Http;

/// <summary>
/// The Nhl.Api HTTP Client
/// </summary>
Expand Down Expand Up @@ -63,8 +62,7 @@ public abstract class NhlApiHttpClient : INhlApiHttpClient
public NhlApiHttpClient(string clientApiUri, string clientVersion, int timeoutInSeconds = 30)

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 62 in Nhl.Api.Common/Http/NhlApiHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'HttpClient' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
ServicePointManager.ReusePort = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;
Client = clientApiUri;
ClientVersion = clientVersion;
Timeout = TimeSpan.FromSeconds(timeoutInSeconds);
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Common/Http/NhlApiWebHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Net.Http;

namespace Nhl.Api.Common.Http;

/// <summary>
/// The dedicated NHL Api Web HTTP Client for the Nhl.Api
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions Nhl.Api.Common/Http/NhlCmsHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Net.Http;

namespace Nhl.Api.Common.Http;


/// <summary>
/// The dedicated NHL HTTP client for NHL player images and content
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Common/Http/NhlEApiHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net.Http;

namespace Nhl.Api.Common.Http;

/// <summary>
/// The dedicated NHLe Api client for the Nhl.Api
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Common/Http/NhlScoresHtmlReportsApiHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net.Http;

namespace Nhl.Api.Common.Http;

/// <summary>
/// The NHL endpoint for HTML reports
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions Nhl.Api.Common/Http/NhlShiftChartHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Net.Http;

namespace Nhl.Api.Common.Http;


/// <summary>
/// The dedicated NHL HTTP client for the shift charts for individual live game feeds
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Common/Http/NhlStaticAssetsApiHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net.Http;

namespace Nhl.Api.Common.Http;

/// <summary>
/// The dedicated NHL static assets HTTP Client for the Nhl.Api
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Common/Http/NhlSuggestionApiHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net.Http;

namespace Nhl.Api.Common.Http;

/// <summary>
/// The dedicated NHL HTTP Client for the NHL suggestion API
/// </summary>
Expand Down
5 changes: 3 additions & 2 deletions Nhl.Api.Common/Nhl.Api.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>3.4.0</Version>
<Version>3.4.1</Version>
<TargetFrameworks>net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
25 changes: 9 additions & 16 deletions Nhl.Api.Common/Services/CachingService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.IO;
Expand All @@ -7,8 +7,6 @@
using System.Threading.Tasks;

namespace Nhl.Api.Common.Services;


/// <summary>
/// A caching service for storing information for easy and quick access within the Nhl.Api
/// </summary>
Expand Down Expand Up @@ -45,31 +43,26 @@ public class CachingService : ICachingService
/// <summary>
/// Clears all cached values
/// </summary>
public void Dispose() => _cacheStore?.Clear();
public void Dispose()
{
_cacheStore?.Clear();
GC.SuppressFinalize(this);
}

/// <summary>
/// Removes the cached item by the key
/// </summary>
public async Task<bool> RemoveAsync(string key)
{
return await Task.Run(() => _cacheStore.TryRemove(key, out var value));
}
public async Task<bool> RemoveAsync(string key) => await Task.Run(() => _cacheStore.TryRemove(key, out var value));

/// <summary>
/// Determines if the key is available within the caching service
/// </summary>
public async Task<bool> ContainsKeyAsync(string key)
{
return await Task.Run(() => _cacheStore.ContainsKey(key));
}
public async Task<bool> ContainsKeyAsync(string key) => await Task.Run(() => _cacheStore.ContainsKey(key));

/// <summary>
/// Add's or updates the cached value based on the provided key and value
/// </summary>
public async Task TryAddUpdateAsync<T>(string key, T value) where T : class
{
_cacheStore.AddOrUpdate(key, await Compress(JsonConvert.SerializeObject(value)), (a, b) => Compress(JsonConvert.SerializeObject(value)).Result);
}
public async Task TryAddUpdateAsync<T>(string key, T value) where T : class => _cacheStore.AddOrUpdate(key, await Compress(JsonConvert.SerializeObject(value)), (a, b) => Compress(JsonConvert.SerializeObject(value)).Result);

/// <summary>
/// Attempts to retrieve the cached value based on the provided key and generic type
Expand Down
11 changes: 2 additions & 9 deletions Nhl.Api.Common/Services/NhlApiAsyncHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;

namespace Nhl.Api.Common.Services;

/// <summary>
/// An asynchronous helper for running asynchronous code in synchronous environments
/// </summary>
Expand All @@ -23,27 +22,21 @@ public static class NhlApiAsyncHelper
/// <typeparam name="TResult">The type of the task result</typeparam>
/// <param name="func">The task that is to be ran in a synchronous manner</param>
/// <returns>The task result</returns>
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
{
return NhlApiAsyncHelper._myTaskFactory
public static TResult RunSync<TResult>(Func<Task<TResult>> func) => NhlApiAsyncHelper._myTaskFactory
.StartNew<Task<TResult>>(func)
.Unwrap<TResult>()
.GetAwaiter()
.GetResult();
}

/// <summary>
/// Takes a asynchronous Task based function and runs it asynchronously in a void manner
/// </summary>
/// <param name="func">The task that is to be ran in a synchronous manner</param>
public static void RunSync(Func<Task> func)
{
NhlApiAsyncHelper._myTaskFactory
public static void RunSync(Func<Task> func) => NhlApiAsyncHelper._myTaskFactory
.StartNew<Task>(func)
.Unwrap()
.GetAwaiter()
.GetResult();
}

/// <summary>
/// A for each iterator that executes with a degree of parallelism for asynchronous function bodies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading.Tasks;

namespace Nhl.Api.Models.Enumerations.Player;

/// <summary>
/// A helper class for generating the <see cref="PlayerEnum"/> values
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Runtime.Serialization;

namespace Nhl.Api.Enumerations.Statistic;

/// <summary>
/// The types of NHL goalie statistics
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Runtime.Serialization;

namespace Nhl.Api.Enumerations.Statistic;

/// <summary>
/// The GameCenter player statistics type for the NHL GameCenter play by play events
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Runtime.Serialization;

namespace Nhl.Api.Enumerations.Statistic;

/// <summary>
/// The types of NHL player statistics
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Domain/Models/Award/Award.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;

namespace Nhl.Api.Models.Award;

/// <summary>
/// NHL Award
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Domain/Models/Draft/Ranks.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;

namespace Nhl.Api.Models.Draft;

/// <summary>
/// NHL Prospect Ranks
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Domain/Models/Franchise/Franchise.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;

namespace Nhl.Api.Models.Franchise;

/// <summary>
/// NHL Franchise
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Domain/Models/Game/Broadcast.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;

namespace Nhl.Api.Models.Game;

/// <summary>
/// Provides information about the home and away NHL broadcasts televised
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Nhl.Api.Domain/Models/Game/Format.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;

namespace Nhl.Api.Models.Game;

/// <summary>
/// NHL Playoff Game Format
/// </summary>
Expand Down
Loading

0 comments on commit 7067ff7

Please sign in to comment.