// Token: 0x060010B5 RID: 4277 RVA: 0x0007A014 File Offset: 0x00078214 private void CheckBytes() { if (this.bytesRead == 0L) { return; } if (this.bytesRead < 0L) { throw new InvalidOperationException("ReportBytes.bytesRead < 0"); } if (this.bytesWritten < 0L) { throw new InvalidOperationException("ReportBytes.bytesWritten < 0"); } if (this.bytesWritten > (long)this.expansionSizeLimit && this.bytesWritten / this.bytesRead > (long)this.expansionSizeMultiple) { throw new TextConvertersException(TextConvertersStrings.DocumentGrowingExcessively(this.expansionSizeMultiple)); } }
internal void WriteTagBegin(HtmlNameIndex nameIndex, string name, bool isEndTag, bool allowWspLeft, bool allowWspRight) { if (outputState != OutputState.OutsideTag) { WriteTagEnd(); } if (literalTags && nameIndex >= HtmlNameIndex.Unknown && (!isEndTag || nameIndex != tagNameIndex)) { throw new InvalidOperationException(TextConvertersStrings.CannotWriteOtherTagsInsideElement(HtmlNameData.names[(int)tagNameIndex].name)); } HtmlTagIndex tagIndex = HtmlNameData.names[(int)nameIndex].tagIndex; if (nameIndex > HtmlNameIndex.Unknown) { isEmptyScopeTag = (HtmlDtd.tags[(int)tagIndex].scope == HtmlDtd.TagScope.EMPTY); if (isEndTag && isEmptyScopeTag) { if (HtmlDtd.tags[(int)tagIndex].unmatchedSubstitute != HtmlTagIndex._IMPLICIT_BEGIN) { output.Write("<!-- </"); lineLength += 7; if (nameIndex > HtmlNameIndex.Unknown) { output.Write(HtmlNameData.names[(int)nameIndex].name); lineLength += HtmlNameData.names[(int)nameIndex].name.Length; } else { output.Write((name != null) ? name : "???"); lineLength += ((name != null) ? name.Length : 3); } output.Write("> "); lineLength += 2; tagNameIndex = HtmlNameIndex._COMMENT; outputState = OutputState.WritingUnstructuredTagContent; return; } isEndTag = false; } } if (autoNewLines && literalWhitespaceNesting == 0) { bool flag = lastWhitespace; HtmlDtd.TagFill fill = HtmlDtd.tags[(int)tagIndex].fill; if (lineLength != 0) { HtmlDtd.TagFmt fmt = HtmlDtd.tags[(int)tagIndex].fmt; if ((!isEndTag && fmt.LB == HtmlDtd.FmtCode.BRK) || (isEndTag && fmt.LE == HtmlDtd.FmtCode.BRK) || (lineLength > 80 && (lastWhitespace || allowWspBeforeFollowingTag || (!isEndTag && fill.LB == HtmlDtd.FillCode.EAT) || (isEndTag && fill.LE == HtmlDtd.FillCode.EAT)))) { if (lineLength > longestLineLength) { longestLineLength = lineLength; } output.Write("\r\n"); lineLength = 0; lastWhitespace = false; } } allowWspBeforeFollowingTag = (((!isEndTag && fill.RB == HtmlDtd.FillCode.EAT) || (isEndTag && fill.RE == HtmlDtd.FillCode.EAT) || (flag && ((!isEndTag && fill.RB == HtmlDtd.FillCode.NUL) || (isEndTag && fill.RE == HtmlDtd.FillCode.NUL)))) && (nameIndex != HtmlNameIndex.Body || !isEndTag)); } if (lastWhitespace) { output.Write(' '); lineLength++; lastWhitespace = false; } if (HtmlDtd.tags[(int)tagIndex].blockElement || tagIndex == HtmlTagIndex.BR) { textLineLength = 0; } output.Write('<'); lineLength++; if (nameIndex >= HtmlNameIndex.Unknown) { if (isEndTag) { if ((byte)(HtmlDtd.tags[(int)tagIndex].literal & HtmlDtd.Literal.Tags) != 0) { literalTags = false; literalEntities = false; cssEscaping = false; } if (HtmlDtd.tags[(int)tagIndex].contextTextType == HtmlDtd.ContextTextType.Literal) { literalWhitespaceNesting--; } output.Write('/'); lineLength++; } if (nameIndex != HtmlNameIndex.Unknown) { output.Write(HtmlNameData.names[(int)nameIndex].name); lineLength += HtmlNameData.names[(int)nameIndex].name.Length; outputState = OutputState.BeforeAttribute; } else { if (name != null) { output.Write(name); lineLength += name.Length; outputState = OutputState.BeforeAttribute; } else { outputState = OutputState.TagStarted; } isEmptyScopeTag = false; } } else { previousTagNameIndex = tagNameIndex; if (nameIndex == HtmlNameIndex._COMMENT) { output.Write("!--"); lineLength += 3; } else if (nameIndex == HtmlNameIndex._ASP) { output.Write('%'); lineLength++; } else if (nameIndex == HtmlNameIndex._CONDITIONAL) { output.Write("!--["); lineLength += 4; } else if (nameIndex == HtmlNameIndex._DTD) { output.Write('?'); lineLength++; } else { output.Write('!'); lineLength++; } outputState = OutputState.WritingUnstructuredTagContent; isEmptyScopeTag = true; } tagNameIndex = nameIndex; this.isEndTag = isEndTag; }