/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/azure/sdk/snippets/unit-testing/ResourceManager/ArmClient.cs
18 строк
493 B
Dapeng Zhang
Add instructions to mock extension methods for resource manager SDKs (#36962)
04 дек 2023, 18:23
Не верифицирован
04 дек 2023, 18:23
a3f0c13
Код
Авторство
О чём код?
using System.ComponentModel; using System.Collections.Concurrent; #nullable disable namespace UnitTestingSampleApp.ResourceManager; public partial class ArmClient { private readonly ConcurrentDictionary<Type, object> _clientCache = new(); [EditorBrowsable(EditorBrowsableState.Never)] public virtual T GetCachedClient<T>(Func<ArmClient, T> clientFactory) where T : class { return (T)_clientCache.GetOrAdd(typeof(T), type => clientFactory(this)); } }