Simplify ReCClient instantiation in Create method
Refactored the `Create` method in the `ReCClient` class to directly resolve a `ReCClient` instance from the dependency injection container using `Provider.GetRequiredService<ReCClient>()`. Removed the intermediate step of retrieving an `IHttpClientFactory` and manually creating a `ReCClient` object. This change reduces boilerplate code and assumes `ReCClient` is already registered in the container, improving maintainability.
This commit is contained in:
parent
23ef1a5797
commit
3f7ebdb632
@ -102,8 +102,7 @@ namespace ReC.Client
|
|||||||
if (Provider == null)
|
if (Provider == null)
|
||||||
throw new InvalidOperationException("Static Provider is not built. Call BuildStaticClient first.");
|
throw new InvalidOperationException("Static Provider is not built. Call BuildStaticClient first.");
|
||||||
|
|
||||||
var httpClientFactory = Provider.GetRequiredService<IHttpClientFactory>();
|
return Provider.GetRequiredService<ReCClient>();
|
||||||
return new ReCClient(httpClientFactory);
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user