-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Labels
Description
As far as I can tell, the given example for "Parameterless" won't work with a class lib targeting .Net Standard 2.0 -- which should be a viable target, as Microsoft.Extensions.DependencyInjection itself targets netstandard2.0? IServiceCollection has no method .AddOptions<T>
using Microsoft.Extensions.DependencyInjection;
namespace ExampleLibrary.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddMyLibraryService(
this IServiceCollection services)
{
services.AddOptions<LibraryOptions>()
.Configure(options =>
{
// Specify default option values
});
// Register lib services here...
// services.AddScoped<ILibraryService, DefaultLibraryService>();
return services;
}
}
}
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 03494bb6-433a-5385-b664-7b830c37f9ce
- Version Independent ID: d0e9398d-50c6-01b8-a242-4edc8b27df31
- Content: Options pattern guidance for .NET library authors
- Content Source: docs/core/extensions/options-library-authors.md
- Product: dotnet-fundamentals
- GitHub Login: @IEvangelist
- Microsoft Alias: dapine
IEvangelist