Skip to content

Commit 2ee60bd

Browse files
Merge pull request #18 from AdrianJSClark/add-options
Rename Main Client, User/Pass on Options, Client Interface Extracted, Save/Restore Cookies
2 parents 9d6e29d + 50d6fbb commit 2ee60bd

File tree

26 files changed

+1161
-807
lines changed

26 files changed

+1161
-807
lines changed

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,26 @@ dotnet add package Aydsko.iRacingData
2525
Register the iRacing Data API client classes with the service provider.
2626

2727
```csharp
28-
services.AddiRacingDataApi();
28+
services.AddiRacingDataApi(options => { options.Username = "your-iracing-user@example.com"; options.Password = "Your-iRacing-Password"; });
2929
```
3030

3131
## Use the Client
3232

33-
Use the injected `iRacingDataClient` to authenticate and request data.
33+
Use the injected `IDataClient` to authenticate and request data.
3434

3535
```csharp
3636
public class ExampleService
3737
{
38-
private readonly iRacingDataClient dataClient;
38+
private readonly IDataClient dataClient;
3939

40-
public ExampleService(iRacingDataClient dataClient)
40+
public ExampleService(IDataClient dataClient)
4141
{
4242
this.dataClient = dataClient;
4343
}
4444

45-
public Task<MemberInfo> GetMyInfoAsync(string username, string password, CancellationToken cancellationToken = default)
45+
public async Task<MemberInfo> GetMyInfoAsync(CancellationToken cancellationToken = default)
4646
{
47-
await dataClient.LoginAsync(username, password, cancellationToken);
4847
var infoResponse = await dataClient.GetMyInfoAsync(cancellationToken);
49-
5048
return infoResponse.Data;
5149
}
5250
}
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using Microsoft.Extensions.DependencyInjection;
22
using Aydsko.iRacingData;
33

4-
using var provider = new ServiceCollection().AddIRacingDataApi()
5-
.BuildServiceProvider();
6-
7-
using var appScope = provider.CreateScope();
8-
94
Console.WriteLine("Aydsko iRacing Data API Example Console Application");
105

116
Console.WriteLine();
@@ -22,15 +17,21 @@
2217
return;
2318
}
2419

25-
var iRacingClient = provider.GetRequiredService<iRacingDataClient>();
26-
await iRacingClient.LoginAsync(username, password);
20+
var services = new ServiceCollection();
21+
services.AddIRacingDataApi(options =>
22+
{
23+
options.Username = username;
24+
options.Password = password;
25+
});
2726

28-
Console.WriteLine();
29-
Console.WriteLine("Login successful!");
27+
using var provider = services.BuildServiceProvider();
28+
using var appScope = provider.CreateScope();
3029

30+
var iRacingClient = provider.GetRequiredService<IDataClient>();
3131
var myInfo = await iRacingClient.GetMyInfoAsync();
3232

3333
Console.WriteLine();
34+
Console.WriteLine("Request successful!");
3435
Console.WriteLine($@"Driver name: {myInfo.Data.DisplayName}
3536
Customer ID: {myInfo.Data.CustomerId}
3637
Club: {myInfo.Data.ClubName}");

examples/Console/iRacingConsole/iRacingConsole.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Aydsko.iRacingData" Version="0.0.6" />
11+
<PackageReference Include="Aydsko.iRacingData" Version="0.1.0" />
1212
</ItemGroup>
1313

1414
</Project>

src/.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ csharp_new_line_before_members_in_anonymous_types = false
1616
#require members of object intializers to be on separate lines
1717
csharp_new_line_before_members_in_object_initializers = true
1818
#require braces to be on a new line for methods, types, and control_blocks (also known as "Allman" style)
19-
csharp_new_line_before_open_brace = methods, types, control_blocks
19+
csharp_new_line_before_open_brace = all
2020

2121
#Formatting - organize using options
2222

@@ -133,6 +133,8 @@ csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
133133
csharp_style_prefer_extended_property_pattern = true:suggestion
134134
csharp_style_prefer_not_pattern = true:suggestion
135135
dotnet_diagnostic.CA1812.severity = silent
136+
csharp_style_prefer_method_group_conversion = true:silent
137+
insert_final_newline = true
136138

137139
[*.{cs,vb}]
138140
dotnet_style_operator_placement_when_wrapping = beginning_of_line

0 commit comments

Comments
 (0)