Skip to content

Commit

Permalink
Adding AzureComponentFactoryWrapper (#2971)
Browse files Browse the repository at this point in the history
  • Loading branch information
alrod authored Apr 4, 2023
1 parent 474b704 commit 9efa258
Showing 1 changed file with 33 additions and 0 deletions.
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);
}
}

0 comments on commit 9efa258

Please sign in to comment.