ProviderCache
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Internal.Builders
{
[NullableContext(1)]
[Nullable(0)]
internal sealed class ProviderCache
{
private readonly Dictionary<Type, object> _instances = new Dictionary<Type, object>();
public object GetInstanceOf(Type providerType)
{
return GetInstanceOf(providerType, null);
}
public object GetInstanceOf(Type providerType, [Nullable(new byte[] {
2,
1
})] object[] providerArgs)
{
if (!_instances.TryGetValue(providerType, out object value))
_instances.Add(providerType, value = Reflect.Construct(providerType, providerArgs));
return value;
}
}
}