mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-24 22:38:46 +00:00
Compare commits
3 Commits
a0b07edc82
...
70cb1b7230
Author | SHA1 | Date | |
---|---|---|---|
70cb1b7230 | |||
22532e8cef | |||
a715384e98 |
10
CHANGELOG.md
10
CHANGELOG.md
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [3.3.0] - 2023-08-21
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- X10D.Hosting: Added support for service/implementation registration with `AddHostedSingleton`.
|
||||||
|
|
||||||
## [3.2.2] - 2023-06-05
|
## [3.2.2] - 2023-06-05
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@ -577,7 +583,9 @@ please [open an issue](https://github.com/oliverbooth/X10D/issues)!
|
|||||||
|
|
||||||
Earlier versions of this package are undocumented and unlisted from package results.
|
Earlier versions of this package are undocumented and unlisted from package results.
|
||||||
|
|
||||||
[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.2.2...main
|
[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.3.0...main
|
||||||
|
[3.3.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.3.0
|
||||||
|
[3.2.2]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.2
|
||||||
[3.2.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.0
|
[3.2.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.0
|
||||||
[3.1.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.1.0
|
[3.1.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.1.0
|
||||||
[3.0.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.0.0
|
[3.0.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.0.0
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<PackageTags>dotnet extension-methods</PackageTags>
|
<PackageTags>dotnet extension-methods</PackageTags>
|
||||||
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
|
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
|
||||||
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
||||||
<VersionPrefix>3.2.2</VersionPrefix>
|
<VersionPrefix>3.3.0</VersionPrefix>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<PackageTags>dotnet extension-methods</PackageTags>
|
<PackageTags>dotnet extension-methods</PackageTags>
|
||||||
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
|
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
|
||||||
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
||||||
<VersionPrefix>3.2.2</VersionPrefix>
|
<VersionPrefix>3.3.0</VersionPrefix>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
@ -21,6 +21,21 @@ public static class ServiceCollectionExtensions
|
|||||||
return services.AddSingleton<IHostedService, TService>(provider => provider.GetRequiredService<TService>());
|
return services.AddSingleton<IHostedService, TService>(provider => provider.GetRequiredService<TService>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds an <see cref="IHostedService" /> registration for the given type, while simultaneously adding it as a singleton.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services">The <see cref="IServiceCollection" /> to add the service to.</param>
|
||||||
|
/// <typeparam name="TService">The type of the service to add.</typeparam>
|
||||||
|
/// <typeparam name="TImplementation">The type of the implementation to use.</typeparam>
|
||||||
|
/// <returns>A reference to this instance after the operation has completed.</returns>
|
||||||
|
public static IServiceCollection AddHostedSingleton<TService, TImplementation>(this IServiceCollection services)
|
||||||
|
where TService : class, IHostedService
|
||||||
|
where TImplementation : class, TService
|
||||||
|
{
|
||||||
|
services.AddSingleton<TService, TImplementation>();
|
||||||
|
return services.AddSingleton<IHostedService, TService>(provider => provider.GetRequiredService<TService>());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds an <see cref="IHostedService" /> registration for the given type, while simultaneously adding it as a singleton.
|
/// Adds an <see cref="IHostedService" /> registration for the given type, while simultaneously adding it as a singleton.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -32,4 +47,19 @@ public static class ServiceCollectionExtensions
|
|||||||
services.AddSingleton(type);
|
services.AddSingleton(type);
|
||||||
return services.AddSingleton(provider => (IHostedService)provider.GetRequiredService(type));
|
return services.AddSingleton(provider => (IHostedService)provider.GetRequiredService(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds an <see cref="IHostedService" /> registration for the given type, while simultaneously adding it as a singleton.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services">The <see cref="IServiceCollection" /> to add the service to.</param>
|
||||||
|
/// <param name="serviceType">The type of the service to register.</param>
|
||||||
|
/// <param name="implementationType">The type of the implementation to use.</param>
|
||||||
|
/// <returns>A reference to this instance after the operation has completed.</returns>
|
||||||
|
public static IServiceCollection AddHostedSingleton(this IServiceCollection services,
|
||||||
|
Type serviceType,
|
||||||
|
Type implementationType)
|
||||||
|
{
|
||||||
|
services.AddSingleton(serviceType, implementationType);
|
||||||
|
return services.AddSingleton(provider => (IHostedService)provider.GetRequiredService(serviceType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<PackageTags>dotnet extension-methods</PackageTags>
|
<PackageTags>dotnet extension-methods</PackageTags>
|
||||||
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
|
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
|
||||||
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
||||||
<VersionPrefix>3.2.2</VersionPrefix>
|
<VersionPrefix>3.3.0</VersionPrefix>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
|
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
|
||||||
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
||||||
<VersionPrefix>3.2.2</VersionPrefix>
|
<VersionPrefix>3.3.0</VersionPrefix>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
Loading…
Reference in New Issue
Block a user