Skip to content

Conversation

@Dreamescaper
Copy link

Fixes #1268

This PR fixes the following:

  • Lifetime parameter now actually works (it was always singleton effectively before)
  • It doesn't build IServiceProvider from IServiceCollection unnessesseraly
  • It doesn't create IMinioClientFactory or IMinioClient until requested

@CamusGao
Copy link

CamusGao commented Oct 28, 2025

Hi, you can use below code to pass the Lifetime parameter to avoid a switch statement.

services.TryAdd(ServiceDescriptor.Describe(typeof(IMinioClient), (sp) =>
{
    var factory = sp.GetRequiredService<IMinioClientFactory>();
    return factory.CreateClient();
}, lifetime));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MinioClient Injection Logic with ServiceLifetime Can Be Confusing

2 participants