public static BufferTextWriter Get(IBufferWriter <byte> bufferWriter) { var writer = Instance ?? new BufferTextWriter(null); //Special initialization to track prior use. Instance = null; // Taken off the thread static #if DEBUG if (writer.InUse) { throw new InvalidOperationException($"The {nameof(BufferTextWriter)} wasn't returned!"); } #endif writer.BufferWriter.Reset(bufferWriter); return(writer); }
public static void Return(BufferTextWriter writer) { writer.BufferWriter.Reset(); Instance = writer; }