-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
167 additions
and
6 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
42 changes: 42 additions & 0 deletions
42
...raftJars.Extension.DependencyInjection/MinecraftJars.Extension.DependencyInjection.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PackageId>MinecraftJars.NET.Extensions.DependencyInjection</PackageId> | ||
<Authors>Patrick Weiss</Authors> | ||
<Product>MinecraftJars.NET.Extensions.DependencyInjection</Product> | ||
<Title>MinecraftJars.NET Dependency Injection Extension</Title> | ||
<PackageProjectUrl>https://github.com/tekgator/MinecraftJars.NET</PackageProjectUrl> | ||
<PackageIcon>MinecraftJarsNET-Logo-128px.png</PackageIcon> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<RepositoryUrl>https://github.com/tekgator/MinecraftJars.NET</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<Description>Dependency injection extension for MinecraftJars.NET</Description> | ||
<Copyright>@Patrick Weiss 2023</Copyright> | ||
<PackageTags>minecraftjars;minecraftjars.net;dependency injection;di</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\MinecraftJars.Core\MinecraftJars.Core.csproj" /> | ||
<ProjectReference Include="..\..\MinecraftJars\MinecraftJars.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\LICENSE"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
<None Include="..\..\Resources\MinecraftJarsNET-Logo-128px.png"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
MinecraftJars.Extension/MinecraftJars.Extension.DependencyInjection/README.md
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,18 @@ | ||
![MinecraftJars.NET dependency injection extensions](../../Resources/MinecraftJarsNET-Logo-64px.png "MinecraftJars.NET dependency injection extensions") | ||
MinecraftJars.NET dependency injection extensions | ||
====== | ||
|
||
## Installing | ||
|
||
Multiple options are available to install within your project: | ||
|
||
1. Install, using the [Nuget Gallery](https://www.nuget.org/packages/MinecraftJars.NET.Extensions.DependencyInjection) | ||
|
||
2. Install using the Package Manager Console: | ||
```ps | ||
Install-Package MinecraftJars.NET.Extensions.DependencyInjection | ||
``` | ||
3. Install using .NET CLI | ||
```cmd | ||
dotnet add package MinecraftJars.NET.Extensions.DependencyInjection | ||
``` |
18 changes: 18 additions & 0 deletions
18
...Jars.Extension/MinecraftJars.Extension.DependencyInjection/ServiceCollectionExtensions.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using MinecraftJars.Core.Providers; | ||
|
||
namespace MinecraftJars.Extension.DependencyInjection; | ||
|
||
public static class ServiceCollectionExtensions | ||
{ | ||
public static IServiceCollection AddMinecraftJar(this IServiceCollection services) | ||
{ | ||
services.AddHttpClient(); | ||
services.AddScoped<IMinecraftJar, MinecraftJar>(sp => new MinecraftJar(new ProviderOptions | ||
{ | ||
HttpClientFactory = sp.GetRequiredService<IHttpClientFactory>() | ||
})); | ||
|
||
return services; | ||
} | ||
} |
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,15 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using MinecraftJars.Extension.DependencyInjection; | ||
|
||
namespace MinecraftJars.Tests; | ||
|
||
[TestFixture, Order(5)] | ||
public class DependencyInjectionTests | ||
{ | ||
[Test] | ||
public void DependencyInjection_Success() | ||
{ | ||
using var serviceProvider = new ServiceCollection().AddMinecraftJar().BuildServiceProvider(); | ||
Assert.That(serviceProvider.GetService<IMinecraftJar>(), Is.Not.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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using MinecraftJars.Core.Projects; | ||
using MinecraftJars.Core.Providers; | ||
|
||
namespace MinecraftJars; | ||
|
||
public interface IMinecraftJar | ||
{ | ||
/// <summary> | ||
/// Return a list of all providers (plugins) | ||
/// </summary> | ||
IEnumerable<IMinecraftProvider> GetProviders(); | ||
|
||
/// <summary> | ||
/// Return a list of all providers offering a certain project group | ||
/// </summary> | ||
IEnumerable<IMinecraftProvider> GetProviders(Group group); | ||
|
||
/// <summary> | ||
/// Return a specific provider | ||
/// </summary> | ||
IMinecraftProvider GetProvider(string provider); | ||
|
||
/// <summary> | ||
/// Return the provider for the provided Project | ||
/// </summary> | ||
IMinecraftProvider GetProvider(IMinecraftProject project); | ||
|
||
/// <summary> | ||
/// Return a list of all projects (e.g. Vanilla, Spigot, etc.) | ||
/// </summary> | ||
IEnumerable<IMinecraftProject> GetProjects(); | ||
|
||
/// <summary> | ||
/// Return a list of all projects for a certain type (e.g. all proxies) | ||
/// </summary> | ||
IEnumerable<IMinecraftProject> GetProjects(Group group); | ||
} |
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