Table of Contents

ServiceLocatorOptions Class

Definition

Namespace
Savvyio.Extensions.DependencyInjection
Assemblies
Savvyio.Extensions.DependencyInjection.dll
Source
src/Savvyio.Extensions.DependencyInjection/ServiceLocatorOptions.cs

Configuration options for IServiceLocator.

public class ServiceLocatorOptions : ServiceOptions, IParameterObject
Inheritance
object
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

Name Description
ServiceLocatorOptions()

Initializes a new instance of the ServiceLocatorOptions class.

Properties

Name Description
ImplementationFactory

Gets or sets the function delegate that creates an instance of an IServiceLocator implementation.

See Also