Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​Extensions.​DependencyInjection.​OptionsServiceCollectionExtensions

Assembly: Microsoft.Extensions.Options

Inheritance: object → OptionsServiceCollectionExtensions

Extension methods for adding options services to the DI container.

Methods

public static IServiceCollection
AddOptions​(IServiceCollection services)
Adds services required for using options.
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
public static Options.​OptionsBuilder<​TOptions>
AddOptionsWithValidateOnStart​(IServiceCollection services, string name = null)
Adds services required for using options and enforces options validation check on start rather than at run time.
Returns The <see cref="T:Microsoft.Extensions.Options.OptionsBuilder`1" /> so that configure calls can be chained in it.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
name The name of the options instance.
Remarks The <see cref="M:Microsoft.Extensions.DependencyInjection.OptionsBuilderExtensions.ValidateOnStart``1(Microsoft.Extensions.Options.OptionsBuilder{``0})" /> extension is called by this method.
public static Options.​OptionsBuilder<​TOptions>
AddOptionsWithValidateOnStart​(IServiceCollection services, string name = null)
Adds services required for using options and enforces options validation check on start rather than at run time.
Returns The <see cref="T:Microsoft.Extensions.Options.OptionsBuilder`1" /> so that configure calls can be chained in it.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
name The name of the options instance.
Remarks The <see cref="M:Microsoft.Extensions.DependencyInjection.OptionsBuilderExtensions.ValidateOnStart``1(Microsoft.Extensions.Options.OptionsBuilder{``0})" /> extension is called by this method.
public static Options.​OptionsBuilder<​TOptions>
AddOptions​(IServiceCollection services)
Gets an options builder that forwards Configure calls for the same <typeparamref name="TOptions" /> to the underlying service collection.
Returns The <see cref="T:Microsoft.Extensions.Options.OptionsBuilder`1" /> so that configure calls can be chained in it.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
public static Options.​OptionsBuilder<​TOptions>
AddOptions​(IServiceCollection services, string name)
Gets an options builder that forwards Configure calls for the same named <typeparamref name="TOptions" /> to the underlying service collection.
Returns The <see cref="T:Microsoft.Extensions.Options.OptionsBuilder`1" /> so that configure calls can be chained in it.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
name The name of the options instance.
public static IServiceCollection
ConfigureAll​(IServiceCollection services, System.​Action<​TOptions> configureOptions)
Registers an action used to configure all instances of a particular type of options.
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
configureOptions The action used to configure the options.
public static IServiceCollection
ConfigureOptions​(IServiceCollection services, object configureInstance)
Registers an object that will have all of its <see cref="T:Microsoft.Extensions.Options.IConfigureOptions`1" /> , <see cref="T:Microsoft.Extensions.Options.IPostConfigureOptions`1" /> , and <see cref="T:Microsoft.Extensions.Options.IValidateOptions`1" /> registered.
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
configureInstance The instance that will configure options.
public static IServiceCollection
ConfigureOptions​(IServiceCollection services, System.​Type configureType)
Registers a type that will have all of its <see cref="T:Microsoft.Extensions.Options.IConfigureOptions`1" /> , <see cref="T:Microsoft.Extensions.Options.IPostConfigureOptions`1" /> , and <see cref="T:Microsoft.Extensions.Options.IValidateOptions`1" /> registered.
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
configureType The type that will configure options.
public static IServiceCollection
ConfigureOptions​(IServiceCollection services)
Registers a type that will have all of its <see cref="T:Microsoft.Extensions.Options.IConfigureOptions`1" /> , <see cref="T:Microsoft.Extensions.Options.IPostConfigureOptions`1" /> , and <see cref="T:Microsoft.Extensions.Options.IValidateOptions`1" /> registered.
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
public static IServiceCollection
Configure​(IServiceCollection services, System.​Action<​TOptions> configureOptions)
Registers an action used to configure a particular type of options. Note: These are run before all <see cref="M:Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.PostConfigure``1(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{``0})" /> .
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
configureOptions The action used to configure the options.
public static IServiceCollection
Configure​(IServiceCollection services, string name, System.​Action<​TOptions> configureOptions)
Registers an action used to configure a particular type of options. Note: These are run before all <see cref="M:Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.PostConfigure``1(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{``0})" /> .
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
name The name of the options instance.
configureOptions The action used to configure the options.
public static IServiceCollection
PostConfigureAll​(IServiceCollection services, System.​Action<​TOptions> configureOptions)
Registers an action used to post configure all instances of a particular type of options. Note: These are run after all <see cref="M:Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure``1(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{``0})" /> .
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
configureOptions The action used to configure the options.
public static IServiceCollection
PostConfigure​(IServiceCollection services, System.​Action<​TOptions> configureOptions)
Registers an action used to initialize a particular type of options. Note: These are run after all <see cref="M:Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure``1(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{``0})" /> .
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
configureOptions The action used to configure the options.
public static IServiceCollection
PostConfigure​(IServiceCollection services, string name, System.​Action<​TOptions> configureOptions)
Registers an action used to configure a particular type of options. Note: These are run after all <see cref="M:Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure``1(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{``0})" /> .
Returns The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> so that additional calls can be chained.
services The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add the services to.
name The name of the options instance.
configureOptions The action used to configure the options.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object