Microsoft.Dependency.Injection similar to Lamar For and Use function

138 Views Asked by At

I would like to ask about Microsoft.Extensions.DependencyInjection library for IoC implementation. Is there a way to do a similar function for the Lamar library function like services.For<TService>().Use<TClient>() in Microsoft.Extension.DependencyInjection?

My code goes like this.

public static void AddSomeServices(this IServiceCollection services, Func<SomeContext> context)
{
    // Similar to this implementation
    services.For<ISomeService>().Use(ctx => context().Extensions.SomeService);
}

Is there a built-in function like this in Microsoft.Extensions.DependencyInjection?

0

There are 0 best solutions below