What is the equivalent code for the ASP.NET Core DI framework from this example using Ninject and .toconstant?

76 Views Asked by At

I am migrating a project that used Ninject to another one that uses ASP.NET Core DI and I'm getting trouble when trying to inject this piece of code in Ninject:

Bind<PlayerService.PlayerServiceClient>()
                .ToConstant(new PlayerService.PlayerServiceClient(new Channel(Configuration.GetValue<string>("playerServiceEndpoint"), ChannelCredentials.Insecure)
                    .Intercept(new PrometheusClientInterceptor())));

How could I translate this?

Thanks you!

1

There are 1 best solutions below

1
Wrong On BEST ANSWER

Okay I could make it work as follows:

services.AddSingleton(new PlayerService.PlayerServiceClient(new Channel(Configuration.GetValue<string>("playerServiceEndpoint"), ChannelCredentials.Insecure)));