Skip to content

Commit 7067ff7

Browse files
authored
Merge pull request #54 from Afischbacher/develop
v3.4.1
2 parents f160400 + 7bfab26 commit 7067ff7

File tree

99 files changed

+1966
-1109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1966
-1109
lines changed

.editorconfig

+444
Large diffs are not rendered by default.

Nhl.Api.Common/Exceptions/InvalidPlayerPositionException.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using System;
1+
using System;
22

33
namespace Nhl.Api.Common.Exceptions;
4-
54
/// <summary>
65
/// An exception for when a request is made to the Nhl.Api and the player/goalie position is invalid
76
/// </summary>

Nhl.Api.Common/Exceptions/InvalidSeasonException.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22

33
namespace Nhl.Api.Common.Exceptions;
4-
54
/// <summary>
65
/// An exception when the season year entered is not a valid NHL season
76
/// </summary>

Nhl.Api.Common/Exceptions/NhlApiRequestException.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22

33
namespace Nhl.Api.Common.Exceptions;
4-
54
/// <summary>
65
/// An exception for a failed Nhl.Api HTTP request
76
/// </summary>

Nhl.Api.Common/Extensions/EnumExtensions.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Runtime.Serialization;
55

66
namespace Nhl.Api.Common.Extensions;
7-
87
/// <summary>
98
/// An enumerations extension class for the Nhl.Api
109
/// </summary>
@@ -16,13 +15,10 @@ public static class EnumExtensions
1615
/// <typeparam name="T">The enumeration type</typeparam>
1716
/// <param name="value">The value of the enumerations</param>
1817
/// <returns>The string value of the enumeration based on the attribute <see cref="EnumMemberAttribute"/></returns>
19-
public static string GetEnumMemberValue<T>(this T value) where T : Enum
20-
{
21-
return typeof(T)
18+
public static string GetEnumMemberValue<T>(this T value) where T : Enum => typeof(T)
2219
.GetTypeInfo()
2320
.DeclaredMembers
2421
.SingleOrDefault(x => x.Name == value.ToString())
2522
?.GetCustomAttribute<EnumMemberAttribute>(false)
2623
?.Value ?? null;
27-
}
2824
}

Nhl.Api.Common/Extensions/StringExtensions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using System.Text.RegularExpressions;
1+
using System.Text.RegularExpressions;
22

33
namespace Nhl.Api.Common.Extensions;
4-
54
/// <summary>
65
/// A helper class for string extensions
76
/// </summary>

Nhl.Api.Common/Helpers/CountryCodeHelper.cs

+494-247
Large diffs are not rendered by default.

Nhl.Api.Common/Helpers/TimeStampHelper.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
1+
using System;
2+
using System.Globalization;
23

34
namespace Nhl.Api.Common.Helpers;
4-
55
/// <summary>
66
/// A helper class to parse the meta data time stamp in Nhl.Api responses
77
/// </summary>
@@ -40,7 +40,7 @@ public class TimeStampHelper
4040
var minute = datetime[1].Substring(2, 2);
4141
var second = datetime[1].Substring(4, 2);
4242

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

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

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

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

Nhl.Api.Common/Http/NhlApiHttpClient.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
22
using System;
33
using System.Net;
44
using System.Net.Http;
55
using System.Threading;
66
using System.Threading.Tasks;
77

88
namespace Nhl.Api.Common.Http;
9-
109
/// <summary>
1110
/// The Nhl.Api HTTP Client
1211
/// </summary>
@@ -63,8 +62,7 @@ public abstract class NhlApiHttpClient : INhlApiHttpClient
6362
public NhlApiHttpClient(string clientApiUri, string clientVersion, int timeoutInSeconds = 30)
6463
{
6564
ServicePointManager.ReusePort = true;
66-
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
67-
65+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;
6866
Client = clientApiUri;
6967
ClientVersion = clientVersion;
7068
Timeout = TimeSpan.FromSeconds(timeoutInSeconds);

Nhl.Api.Common/Http/NhlApiWebHttpClient.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Net.Http;
44

55
namespace Nhl.Api.Common.Http;
6-
76
/// <summary>
87
/// The dedicated NHL Api Web HTTP Client for the Nhl.Api
98
/// </summary>

Nhl.Api.Common/Http/NhlCmsHttpClient.cs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using System.Net.Http;
33

44
namespace Nhl.Api.Common.Http;
5-
6-
75
/// <summary>
86
/// The dedicated NHL HTTP client for NHL player images and content
97
/// </summary>

Nhl.Api.Common/Http/NhlEApiHttpClient.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Net.Http;
33

44
namespace Nhl.Api.Common.Http;
5-
65
/// <summary>
76
/// The dedicated NHLe Api client for the Nhl.Api
87
/// </summary>

Nhl.Api.Common/Http/NhlScoresHtmlReportsApiHttpClient.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Net.Http;
33

44
namespace Nhl.Api.Common.Http;
5-
65
/// <summary>
76
/// The NHL endpoint for HTML reports
87
/// </summary>

Nhl.Api.Common/Http/NhlShiftChartHttpClient.cs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using System.Net.Http;
33

44
namespace Nhl.Api.Common.Http;
5-
6-
75
/// <summary>
86
/// The dedicated NHL HTTP client for the shift charts for individual live game feeds
97
/// </summary>

Nhl.Api.Common/Http/NhlStaticAssetsApiHttpClient.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Net.Http;
33

44
namespace Nhl.Api.Common.Http;
5-
65
/// <summary>
76
/// The dedicated NHL static assets HTTP Client for the Nhl.Api
87
/// </summary>

Nhl.Api.Common/Http/NhlSuggestionApiHttpClient.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Net.Http;
33

44
namespace Nhl.Api.Common.Http;
5-
65
/// <summary>
76
/// The dedicated NHL HTTP Client for the NHL suggestion API
87
/// </summary>

Nhl.Api.Common/Nhl.Api.Common.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Version>3.4.0</Version>
4+
<Version>3.4.1</Version>
55
<TargetFrameworks>net8.0</TargetFrameworks>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7+
<Nullable>enable</Nullable>
78
</PropertyGroup>
89

910
<ItemGroup>

Nhl.Api.Common/Services/CachingService.cs

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
22
using System;
33
using System.Collections.Concurrent;
44
using System.IO;
@@ -7,8 +7,6 @@
77
using System.Threading.Tasks;
88

99
namespace Nhl.Api.Common.Services;
10-
11-
1210
/// <summary>
1311
/// A caching service for storing information for easy and quick access within the Nhl.Api
1412
/// </summary>
@@ -45,31 +43,26 @@ public class CachingService : ICachingService
4543
/// <summary>
4644
/// Clears all cached values
4745
/// </summary>
48-
public void Dispose() => _cacheStore?.Clear();
46+
public void Dispose()
47+
{
48+
_cacheStore?.Clear();
49+
GC.SuppressFinalize(this);
50+
}
4951

5052
/// <summary>
5153
/// Removes the cached item by the key
5254
/// </summary>
53-
public async Task<bool> RemoveAsync(string key)
54-
{
55-
return await Task.Run(() => _cacheStore.TryRemove(key, out var value));
56-
}
55+
public async Task<bool> RemoveAsync(string key) => await Task.Run(() => _cacheStore.TryRemove(key, out var value));
5756

5857
/// <summary>
5958
/// Determines if the key is available within the caching service
6059
/// </summary>
61-
public async Task<bool> ContainsKeyAsync(string key)
62-
{
63-
return await Task.Run(() => _cacheStore.ContainsKey(key));
64-
}
60+
public async Task<bool> ContainsKeyAsync(string key) => await Task.Run(() => _cacheStore.ContainsKey(key));
6561

6662
/// <summary>
6763
/// Add's or updates the cached value based on the provided key and value
6864
/// </summary>
69-
public async Task TryAddUpdateAsync<T>(string key, T value) where T : class
70-
{
71-
_cacheStore.AddOrUpdate(key, await Compress(JsonConvert.SerializeObject(value)), (a, b) => Compress(JsonConvert.SerializeObject(value)).Result);
72-
}
65+
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);
7366

7467
/// <summary>
7568
/// Attempts to retrieve the cached value based on the provided key and generic type

Nhl.Api.Common/Services/NhlApiAsyncHelper.cs

+2-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading.Tasks;
66

77
namespace Nhl.Api.Common.Services;
8-
98
/// <summary>
109
/// An asynchronous helper for running asynchronous code in synchronous environments
1110
/// </summary>
@@ -23,27 +22,21 @@ public static class NhlApiAsyncHelper
2322
/// <typeparam name="TResult">The type of the task result</typeparam>
2423
/// <param name="func">The task that is to be ran in a synchronous manner</param>
2524
/// <returns>The task result</returns>
26-
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
27-
{
28-
return NhlApiAsyncHelper._myTaskFactory
25+
public static TResult RunSync<TResult>(Func<Task<TResult>> func) => NhlApiAsyncHelper._myTaskFactory
2926
.StartNew<Task<TResult>>(func)
3027
.Unwrap<TResult>()
3128
.GetAwaiter()
3229
.GetResult();
33-
}
3430

3531
/// <summary>
3632
/// Takes a asynchronous Task based function and runs it asynchronously in a void manner
3733
/// </summary>
3834
/// <param name="func">The task that is to be ran in a synchronous manner</param>
39-
public static void RunSync(Func<Task> func)
40-
{
41-
NhlApiAsyncHelper._myTaskFactory
35+
public static void RunSync(Func<Task> func) => NhlApiAsyncHelper._myTaskFactory
4236
.StartNew<Task>(func)
4337
.Unwrap()
4438
.GetAwaiter()
4539
.GetResult();
46-
}
4740

4841
/// <summary>
4942
/// A for each iterator that executes with a degree of parallelism for asynchronous function bodies

Nhl.Api.Domain/Enumerations/Player/PlayerEnumFileGeneratorHelper.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Threading.Tasks;
88

99
namespace Nhl.Api.Models.Enumerations.Player;
10-
1110
/// <summary>
1211
/// A helper class for generating the <see cref="PlayerEnum"/> values
1312
/// </summary>

Nhl.Api.Domain/Enumerations/Statistic/GoalieStatisticsType.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Runtime.Serialization;
22

33
namespace Nhl.Api.Enumerations.Statistic;
4-
54
/// <summary>
65
/// The types of NHL goalie statistics
76
/// </summary>

Nhl.Api.Domain/Enumerations/Statistic/PlayerGameCenterStatistic.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Runtime.Serialization;
22

33
namespace Nhl.Api.Enumerations.Statistic;
4-
54
/// <summary>
65
/// The GameCenter player statistics type for the NHL GameCenter play by play events
76
/// </summary>

Nhl.Api.Domain/Enumerations/Statistic/PlayerStatisticsType.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Runtime.Serialization;
22

33
namespace Nhl.Api.Enumerations.Statistic;
4-
54
/// <summary>
65
/// The types of NHL player statistics
76
/// </summary>

Nhl.Api.Domain/Models/Award/Award.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Newtonsoft.Json;
22

33
namespace Nhl.Api.Models.Award;
4-
54
/// <summary>
65
/// NHL Award
76
/// </summary>

Nhl.Api.Domain/Models/Draft/Ranks.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Newtonsoft.Json;
22

33
namespace Nhl.Api.Models.Draft;
4-
54
/// <summary>
65
/// NHL Prospect Ranks
76
/// </summary>

Nhl.Api.Domain/Models/Franchise/Franchise.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Newtonsoft.Json;
22

33
namespace Nhl.Api.Models.Franchise;
4-
54
/// <summary>
65
/// NHL Franchise
76
/// </summary>

Nhl.Api.Domain/Models/Game/Broadcast.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Newtonsoft.Json;
22

33
namespace Nhl.Api.Models.Game;
4-
54
/// <summary>
65
/// Provides information about the home and away NHL broadcasts televised
76
/// </summary>

Nhl.Api.Domain/Models/Game/Format.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Newtonsoft.Json;
22

33
namespace Nhl.Api.Models.Game;
4-
54
/// <summary>
65
/// NHL Playoff Game Format
76
/// </summary>

0 commit comments

Comments
 (0)