This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from KSoft-Si/refit-rewrite
- Loading branch information
Showing
77 changed files
with
3,724 additions
and
1,295 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\KSoftNet\KSoftNet.csproj" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Threading.Tasks; | ||
using KSoftNet; | ||
|
||
namespace CustomHttpclient { | ||
internal static class Program { | ||
private const string Token = "{token}"; | ||
|
||
private static void Main() { | ||
new ExampleClass(Token).GetRandomImage("birb").GetAwaiter().GetResult(); | ||
} | ||
} | ||
|
||
public class ExampleClass { | ||
private readonly KSoftApi _kSoftApi; | ||
|
||
public ExampleClass(string token) { | ||
var httpClient = new HttpClient { | ||
BaseAddress = new Uri("https://api.ksoft.si"), | ||
DefaultRequestHeaders = { | ||
Authorization = new AuthenticationHeaderValue("Bearer", token) | ||
} | ||
}; | ||
|
||
_kSoftApi = new KSoftApi(httpClient); | ||
} | ||
|
||
public async Task GetRandomImage(string tag) { | ||
var image = await _kSoftApi.ImagesApi.GetRandomImage(tag: tag); | ||
|
||
Console.WriteLine(image.Url); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\KSoftNet\KSoftNet.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Threading.Tasks; | ||
using KSoftNet; | ||
using KSoftNet.Models.Images; | ||
|
||
namespace DependencyInjection { | ||
public class ExampleClass { | ||
private readonly KSoftApi _kSoftApi; | ||
|
||
public ExampleClass(KSoftApi kSoftApi) { | ||
_kSoftApi = kSoftApi; | ||
} | ||
|
||
public async Task<Image> GetRandomImage(string tag) { | ||
var image = await _kSoftApi.ImagesApi.GetRandomImage(tag: tag); | ||
|
||
return image; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using KSoftNet; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace DependencyInjection { | ||
internal static class Program { | ||
|
||
private static void Main() { | ||
var startup = new Startup(); | ||
startup.Init(); | ||
startup.RunAsync().GetAwaiter().GetResult(); | ||
} | ||
} | ||
|
||
public class Startup { | ||
private const string Token = "{token}"; | ||
private KSoftApi _kSoftApi; | ||
|
||
private IServiceProvider _serviceProvider; | ||
|
||
public void Init() { | ||
var services = new ServiceCollection(); | ||
|
||
_kSoftApi = new KSoftApi(Token); | ||
|
||
ConfigureServices(services); | ||
_serviceProvider = services.BuildServiceProvider(); | ||
} | ||
|
||
public async Task RunAsync() { | ||
var exampleClass = _serviceProvider.GetService<ExampleClass>(); | ||
|
||
var image = await exampleClass.GetRandomImage("birb"); | ||
|
||
Console.WriteLine(image.Url); | ||
} | ||
|
||
private void ConfigureServices(IServiceCollection services) { | ||
services.AddSingleton(_kSoftApi); | ||
services.AddSingleton<ExampleClass>(); | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\KSoftNet\KSoftNet.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.