Skip to content

Commit

Permalink
reuse set provider logic
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Petrusevici <V.Petrusevici@maib.md>
  • Loading branch information
Vladimir Petrusevici authored and Vladimir Petrusevici committed Oct 27, 2023
1 parent ad43085 commit b740910
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/OpenFeature/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,16 @@ private Api() { }
/// </summary>
/// <param name="featureProvider">Implementation of <see cref="FeatureProvider"/></param>
public void SetProvider(FeatureProvider featureProvider)
{
this._featureProviderLock.EnterWriteLock();
try
{
this._defaultProviderFunc = featureProvider != null ? () => featureProvider : this._defaultProviderFunc;
}
finally
{
this._featureProviderLock.ExitWriteLock();
}
}
=> this.SetProvider(featureProvider == null ? (Func<FeatureProvider>) null : () => featureProvider);

/// <summary>
/// Sets the feature provider to given clientName
/// </summary>
/// <param name="clientName">Name of client</param>
/// <param name="featureProvider">Implementation of <see cref="FeatureProvider"/></param>
public void SetProvider(string clientName, FeatureProvider featureProvider)
{
FeatureProvider func() => featureProvider;
this._featureProviders.AddOrUpdate(clientName, func,
(key, current) => func);
}
=> this.SetProvider(clientName, featureProvider == null ? (Func<FeatureProvider>)null : () => featureProvider);


/// <summary>
/// Sets the feature provider
Expand Down

0 comments on commit b740910

Please sign in to comment.