/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/azure/sdk/snippets/unit-testing/ResourceManager/ArmCollection.cs
32 строки
807 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; using Azure.Core; #nullable disable namespace UnitTestingSampleApp.ResourceManager; public abstract partial class ArmCollection { protected ArmCollection() { } protected internal ArmCollection(ArmClient client, ResourceIdentifier id) { Client = client; Id = id; } public virtual ResourceIdentifier Id { get; } protected internal virtual ArmClient Client { get; } 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(Client)); } }