DelegateCacheProvider
class DelegateCacheProvider
using Stashbox.Utils;
using Stashbox.Utils.Data.Immutable;
using System.Runtime.CompilerServices;
namespace Stashbox.Resolution
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal class DelegateCacheProvider
{
public readonly DelegateCache DefaultCache = new DelegateCache();
public ImmutableTree<object, DelegateCache> NamedCache = ImmutableTree<object, DelegateCache>.Empty;
public DelegateCache GetNamedCache(object name)
{
DelegateCache orDefaultByValue = NamedCache.GetOrDefaultByValue(name);
if (orDefaultByValue != null)
return orDefaultByValue;
DelegateCache delegateCache = new DelegateCache();
object delegateCache2;
if (!Swap.SwapValue<object, DelegateCache, byte, byte, ImmutableTree<object, DelegateCache>>(ref NamedCache, (object t1, DelegateCache t2, byte _, byte _, ImmutableTree<object, DelegateCache> items) => items.AddOrUpdate(t1, t2, false, null), name, delegateCache, 0, 0)) {
delegateCache2 = NamedCache.GetOrDefaultByValue(name);
if (delegateCache2 == null)
return delegateCache;
} else
delegateCache2 = delegateCache;
return (DelegateCache)delegateCache2;
}
}
}