<PackageReference Include="System.Text.Json" Version="6.0.0" />

ConcurrentQueueOfTConverter<TCollection, TElement>

sealed class ConcurrentQueueOfTConverter<TCollection, TElement> : IEnumerableDefaultConverter<TCollection, TElement> where TCollection : ConcurrentQueue<TElement>
using System.Collections.Concurrent; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Text.Json.Serialization.Converters { internal sealed class ConcurrentQueueOfTConverter<TCollection, TElement> : IEnumerableDefaultConverter<TCollection, TElement> where TCollection : ConcurrentQueue<TElement> { protected override void Add([In] [System.Runtime.CompilerServices.IsReadOnly] TElement value, ref ReadStack state) { ((TCollection)state.Current.ReturnValue).Enqueue(value); } protected override void CreateCollection(ref Utf8JsonReader reader, ref ReadStack state, JsonSerializerOptions options) { if (state.Current.JsonTypeInfo.CreateObject == null) ThrowHelper.ThrowNotSupportedException_SerializationNotSupported(state.Current.JsonTypeInfo.Type); state.Current.ReturnValue = state.Current.JsonTypeInfo.CreateObject(); } } }