Class ServiceLocatorOptions
- Namespace
- Savvyio.Extensions.DependencyInjection
- Assembly
- Savvyio.Extensions.DependencyInjection.dll
Configuration options for IServiceLocator.
public class ServiceLocatorOptions : ServiceOptions, IParameterObject
- Inheritance
-
ServiceLocatorOptions
- Implements
- Inherited Members
Examples
Configure a ServiceLocatorOptions instance to provide a custom IServiceLocator factory, passed to AddServiceLocator.
using Microsoft.Extensions.DependencyInjection;
using Savvyio.Dispatchers;
using Savvyio.Extensions.DependencyInjection;
namespace ExampleApp;
public static class ServiceLocatorSetup
{
public static IServiceCollection AddLocator(this IServiceCollection services)
{
services.AddServiceLocator(ConfigureLocator);
return services;
}
private static void ConfigureLocator(ServiceLocatorOptions options)
{
options.Lifetime = ServiceLifetime.Singleton;
options.ImplementationFactory = provider => new ServiceLocator(provider.GetServices);
}
}
Constructors
ServiceLocatorOptions()
Initializes a new instance of the ServiceLocatorOptions class.
public ServiceLocatorOptions()
Remarks
The following table shows the initial property values for an instance of ServiceLocatorOptions.
| Property | Initial Value |
|---|---|
| ImplementationFactory | p => new ServiceLocator(p.GetServices) |
Properties
ImplementationFactory
Gets or sets the function delegate that creates an instance of an IServiceLocator implementation.
public Func<IServiceProvider, IServiceLocator> ImplementationFactory { get; set; }
Property Value
- Func<IServiceProvider, IServiceLocator>
The function delegate that creates an instance of an IServiceLocator implementation.