-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename Camille.RiotApi to Camille.RiotGames, add 'Api' suffix to clas…
…ses #43
- Loading branch information
1 parent
4882fb1
commit 1543d8f
Showing
49 changed files
with
891 additions
and
891 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Camille.Lcu | ||
{ | ||
public interface ILcu | ||
{ | ||
/// <summary> | ||
/// Send a custom request to the LCU, parsing a value as JSON. | ||
/// </summary> | ||
/// <typeparam name="T">Type to parse as JSON.</typeparam> | ||
/// <param name="request">Request to send.</param> | ||
/// <param name="token">Cancellation token to cancel the request.</param> | ||
/// <returns>The parsed value. May be null if endpoint returned an empty success response.</returns> | ||
public Task<T> Send<T>(HttpRequestMessage request, CancellationToken? token = null); | ||
|
||
/// <summary> | ||
/// Send a custom request to the LCU, ignoring the return value. | ||
/// </summary> | ||
/// <typeparam name="T">Type to parse as JSON.</typeparam> | ||
/// <param name="request">Request to send.</param> | ||
/// <param name="token">Cancellation token to cancel the request.</param> | ||
public Task Send(HttpRequestMessage request, CancellationToken? token = null); | ||
} | ||
} | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Camille.Lcu | ||
{ | ||
public interface ILcuApi | ||
{ | ||
/// <summary> | ||
/// Send a custom request to the LCU, parsing a value as JSON. | ||
/// </summary> | ||
/// <typeparam name="T">Type to parse as JSON.</typeparam> | ||
/// <param name="request">Request to send.</param> | ||
/// <param name="token">Cancellation token to cancel the request.</param> | ||
/// <returns>The parsed value. May be null if endpoint returned an empty success response.</returns> | ||
public Task<T> Send<T>(HttpRequestMessage request, CancellationToken? token = null); | ||
|
||
/// <summary> | ||
/// Send a custom request to the LCU, ignoring the return value. | ||
/// </summary> | ||
/// <typeparam name="T">Type to parse as JSON.</typeparam> | ||
/// <param name="request">Request to send.</param> | ||
/// <param name="token">Cancellation token to cancel the request.</param> | ||
public Task Send(HttpRequestMessage request, CancellationToken? token = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
using Camille.Lcu.Util; | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Camille.Lcu | ||
{ | ||
public class Lcu : ILcu, IDisposable | ||
{ | ||
private readonly LcuRequester _requester; | ||
public readonly Wamp wamp; | ||
|
||
public Lcu(Lockfile lockfile) : this(lockfile, new LcuConfig()) | ||
{} | ||
|
||
public Lcu(Lockfile lockfile, LcuConfig config) : base() | ||
{ | ||
_requester = new LcuRequester(lockfile, config); | ||
wamp = new Wamp(lockfile, config); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<T> Send<T>(HttpRequestMessage request, CancellationToken? token = null) | ||
{ | ||
// Camille's code is context-free. | ||
// This slightly improves performance and helps prevent GUI thread deadlocks. | ||
// https://blogs.msdn.microsoft.com/benwilli/2017/02/09/an-alternative-to-configureawaitfalse-everywhere/ | ||
await new SynchronizationContextRemover(); | ||
var content = await _requester.SendAsync(request, token.GetValueOrDefault()); | ||
if (null == content) return default!; // TODO: throw exception on unexpected null. | ||
#if USE_NEWTONSOFT | ||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(content); | ||
#elif USE_SYSTEXTJSON | ||
return System.Text.Json.JsonSerializer.Deserialize<T>(content); | ||
#else | ||
#error Must have one of USE_NEWTONSOFT or USE_SYSTEXTJSON set. | ||
#endif | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task Send(HttpRequestMessage request, CancellationToken? token = null) | ||
{ | ||
await new SynchronizationContextRemover(); | ||
await _requester.SendAsync(request, token.GetValueOrDefault()); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_requester.Dispose(); | ||
wamp.Dispose(); | ||
} | ||
} | ||
} | ||
using Camille.Lcu.Util; | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Camille.Lcu | ||
{ | ||
public class LcuApi : ILcuApi, IDisposable | ||
{ | ||
private readonly LcuRequester _requester; | ||
public readonly Wamp wamp; | ||
|
||
public LcuApi(Lockfile lockfile) : this(lockfile, new LcuConfig()) | ||
{} | ||
|
||
public LcuApi(Lockfile lockfile, LcuConfig config) : base() | ||
{ | ||
_requester = new LcuRequester(lockfile, config); | ||
wamp = new Wamp(lockfile, config); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<T> Send<T>(HttpRequestMessage request, CancellationToken? token = null) | ||
{ | ||
// Camille's code is context-free. | ||
// This slightly improves performance and helps prevent GUI thread deadlocks. | ||
// https://blogs.msdn.microsoft.com/benwilli/2017/02/09/an-alternative-to-configureawaitfalse-everywhere/ | ||
await new SynchronizationContextRemover(); | ||
var content = await _requester.SendAsync(request, token.GetValueOrDefault()); | ||
if (null == content) return default!; // TODO: throw exception on unexpected null. | ||
#if USE_NEWTONSOFT | ||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(content); | ||
#elif USE_SYSTEXTJSON | ||
return System.Text.Json.JsonSerializer.Deserialize<T>(content); | ||
#else | ||
#error Must have one of USE_NEWTONSOFT or USE_SYSTEXTJSON set. | ||
#endif | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task Send(HttpRequestMessage request, CancellationToken? token = null) | ||
{ | ||
await new SynchronizationContextRemover(); | ||
await _requester.SendAsync(request, token.GetValueOrDefault()); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_requester.Dispose(); | ||
wamp.Dispose(); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Camille.RiotApi.Test/.gitignore → Camille.RiotGames.Test/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
apikey.txt | ||
apikey.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
....RiotApi.Test/ApiChampionMasteryV4Test.cs → ...iotGames.Test/ApiChampionMasteryV4Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Camille.RiotApi.Test/ApiChampionV3Test.cs → Camille.RiotGames.Test/ApiChampionV3Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Camille.RiotApi.Test/ApiLorRankedV1Test.cs → Camille.RiotGames.Test/ApiLorRankedV1Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 23 additions & 23 deletions
46
....RiotApi.Test/Camille.RiotApi.Test.csproj → ...tGames.Test/Camille.RiotGames.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp2.0;netcoreapp3.1</TargetFrameworks> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Camille.Enums\Camille.Enums.csproj" /> | ||
<ProjectReference Include="..\Camille.RiotApi\Camille.RiotApi.csproj" /> | ||
|
||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="apikey.txt"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp2.0;netcoreapp3.1</TargetFrameworks> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Camille.Enums\Camille.Enums.csproj" /> | ||
<ProjectReference Include="..\Camille.RiotGames\Camille.RiotGames.csproj" /> | ||
|
||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="apikey.txt"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.