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