Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteStreamAsync< TValue >()

static async Task System.Text.Json.JsonSerializer.WriteStreamAsync< TValue > ( Stream utf8Json,
TValue value,
JsonTypeInfo jsonTypeInfo,
CancellationToken cancellationToken )
inlinestaticprivate

Definition at line 1748 of file JsonSerializer.cs.

1749 {
1750 JsonSerializerOptions options = jsonTypeInfo.Options;
1751 JsonWriterOptions writerOptions = options.GetWriterOptions();
1752 using PooledByteBufferWriter bufferWriter = new PooledByteBufferWriter(options.DefaultBufferSize);
1753 using Utf8JsonWriter writer = new Utf8JsonWriter(bufferWriter, writerOptions);
1754 WriteStack state = new WriteStack
1755 {
1757 };
1759 try
1760 {
1761 bool isFinalBlock;
1762 do
1763 {
1764 state.FlushThreshold = (int)((float)bufferWriter.Capacity * 0.9f);
1765 try
1766 {
1768 if (state.SuppressFlush)
1769 {
1770 state.SuppressFlush = false;
1771 continue;
1772 }
1773 await bufferWriter.WriteToStreamAsync(utf8Json, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
1775 }
1776 finally
1777 {
1778 if (state.PendingTask != null)
1779 {
1780 try
1781 {
1782 await state.PendingTask.ConfigureAwait(continueOnCapturedContext: false);
1783 }
1784 catch
1785 {
1786 }
1787 }
1788 List<IAsyncDisposable> completedAsyncDisposables = state.CompletedAsyncDisposables;
1790 {
1791 await state.DisposeCompletedAsyncDisposables().ConfigureAwait(continueOnCapturedContext: false);
1792 }
1793 }
1794 }
1795 while (!isFinalBlock);
1796 }
1797 catch
1798 {
1799 await state.DisposePendingDisposablesOnExceptionAsync().ConfigureAwait(continueOnCapturedContext: false);
1800 throw;
1801 }
1802 }
virtual void Initialize(JsonSerializerOptions options, JsonTypeInfo jsonTypeInfo=null)

References System.cancellationToken, System.Collections.Generic.Dictionary< TKey, TValue >.Clear(), System.converter, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Text.Json.Dictionary, System.Text.Json.Serialization.JsonConverter< T >.Initialize(), System.options, System.state, System.value, and System.writer.