-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding AzureComponentFactoryWrapper (#2971)
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
test/Microsoft.Azure.WebJobs.Host.TestCommon/AzureComponentFactoryWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Microsoft.Extensions.Azure; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Microsoft.Azure.WebJobs.Host.TestCommon | ||
{ | ||
public class AzureComponentFactoryWrapper : AzureComponentFactory | ||
{ | ||
private readonly AzureComponentFactory _factory; | ||
private readonly TokenCredential _tokenCredential; | ||
|
||
public AzureComponentFactoryWrapper(AzureComponentFactory factory, TokenCredential tokenCredential) | ||
{ | ||
_factory = factory; | ||
_tokenCredential = tokenCredential; | ||
} | ||
|
||
public override TokenCredential CreateTokenCredential(IConfiguration configuration) | ||
{ | ||
return _tokenCredential != null ? _tokenCredential : _factory.CreateTokenCredential(configuration); | ||
} | ||
|
||
public override object CreateClientOptions(Type optionsType, object serviceVersion, IConfiguration configuration) | ||
=> _factory.CreateClientOptions(optionsType, serviceVersion, configuration); | ||
|
||
public override object CreateClient(Type clientType, IConfiguration configuration, TokenCredential credential, object clientOptions) | ||
=> _factory.CreateClient(clientType, configuration, credential, clientOptions); | ||
} | ||
} |