/// <summary> /// Creates a new CodedInputStream reading data from the given /// stream and buffer, using the default limits. /// </summary> internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, bool leaveOpen) { this.input = input; this.buffer = buffer; this.state.bufferPos = bufferPos; this.state.bufferSize = bufferSize; this.state.sizeLimit = DefaultSizeLimit; this.state.recursionLimit = DefaultRecursionLimit; SegmentedBufferHelper.Initialize(this, out this.state.segmentedBufferHelper); this.leaveOpen = leaveOpen; this.state.currentLimit = int.MaxValue; }
internal static void Initialize(ReadOnlySequence <byte> input, int recursionLimit, out ParseContext ctx) { ctx.buffer = default; ctx.state = default; ctx.state.lastTag = 0; ctx.state.recursionDepth = 0; ctx.state.sizeLimit = DefaultSizeLimit; ctx.state.recursionLimit = recursionLimit; ctx.state.currentLimit = int.MaxValue; SegmentedBufferHelper.Initialize(input, out ctx.state.segmentedBufferHelper, out ctx.buffer); ctx.state.bufferPos = 0; ctx.state.bufferSize = ctx.buffer.Length; ctx.state.DiscardUnknownFields = false; ctx.state.ExtensionRegistry = null; }