2 instantiations of CachingContext
System.Text.Json (2)
System\Text\Json\Serialization\JsonSerializerOptions.Caching.cs (2)
419
return new
CachingContext
(options, hashCode);
429
var ctx = new
CachingContext
(options, hashCode);
16 references to CachingContext
System.Text.Json (16)
System\Text\Json\Serialization\JsonSerializerOptions.Caching.cs (16)
23
internal
CachingContext
CacheContext
30
CachingContext
GetOrCreate()
32
CachingContext
ctx = TrackedCachingContexts.GetOrCreate(this);
38
private
CachingContext
? _cachingContext;
264
private static CacheEntry CreateCacheEntry(Type type,
CachingContext
context)
396
/// this approach uses a fixed-size array of weak references of <see cref="
CachingContext
"/> that can be looked up lock-free.
402
private static readonly WeakReference<
CachingContext
>?[] s_trackedContexts = new WeakReference<
CachingContext
>[MaxTrackedContexts];
405
public static
CachingContext
GetOrCreate(JsonSerializerOptions options)
412
if (TryGetContext(options, hashCode, out int firstUnpopulatedIndex, out
CachingContext
? result))
429
var
ctx = new CachingContext(options, hashCode);
434
ref WeakReference<
CachingContext
>? weakRef = ref s_trackedContexts[firstUnpopulatedIndex];
455
[NotNullWhen(true)] out
CachingContext
? result)
457
WeakReference<
CachingContext
>?[] trackedContexts = s_trackedContexts;
462
WeakReference<
CachingContext
>? weakRef = trackedContexts[i];
464
if (weakRef is null || !weakRef.TryGetTarget(out
CachingContext
? ctx))