NClient icon indicating copy to clipboard operation
NClient copied to clipboard

Named client

Open smolchanovsky opened this issue 3 years ago • 1 comments

A named client will allow you to use named options when creating via DI:

services.Configure<JsonSerializerOptions>(name: "myClient", options =>
{
    options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
});
services.AddNClient<IFileClient>(name: "myClient", host: "http://localhost:5001");    // Use myClient JsonSerializerOptions

smolchanovsky avatar Mar 13 '22 14:03 smolchanovsky

I really don't sure that is a good opportunity.
First of all how many times do you re-use options? I think we can just create override AddNClient with options default parameter or extension method WithOptions (if it isn't exist) Secondly, string const make me sad every time I've see this. Pure refactoring ability is breaking. And last but not least... The "name" can be used for any different connections. So... How you suggest resolve the situation when we want to apply same options by name but for multiple clients?

Kingmidas74 avatar Sep 03 '22 08:09 Kingmidas74