private static string GetBuilderContent(StringBuilder builder, XmlSpace xmlSpace, WhitespaceSignificant whitespaceSignificant, WhitespaceTrimming leadingWhitespace, WhitespaceTrimming trailingWhitespace) { int length1 = builder.Length; if (length1 > 0) { if (xmlSpace == XmlSpace.Preserve) { if (whitespaceSignificant == WhitespaceSignificant.Significant || ElementContentBuilder.ContainsNonWhitespace(builder)) { return(builder.ToString()); } } else { char[] chArray = new char[length1]; int length2 = 0; int num = -1; for (int index = 0; index < length1; ++index) { char c = builder[index]; if (!Scanner.IsXmlWhitespace(c)) { if (index > num + 1 && (length2 > 0 || leadingWhitespace == WhitespaceTrimming.Include)) { chArray[length2++] = ' '; } chArray[length2++] = c; num = index; } } if (length1 > num + 1 && trailingWhitespace == WhitespaceTrimming.Include && (length2 > 0 || whitespaceSignificant == WhitespaceSignificant.Significant && leadingWhitespace == WhitespaceTrimming.Include)) { chArray[length2++] = ' '; } if (length2 > 0) { return(new string(chArray, 0, length2)); } } } return((string)null); }
public ElementContentBuilder(XmlSpace xmlSpace, WhitespaceSignificant whitespaceSignificant) { this.xmlSpace = xmlSpace; this.whitespaceSignificant = whitespaceSignificant; }