private string Logic_ApplyFinalTextTrimming(XamlText text) { ScannerNodeType peekNodeType = this._xamlScanner.PeekNodeType; string source = text.Text; if (!text.IsSpacePreserved) { switch (peekNodeType) { case ScannerNodeType.ENDTAG: case ScannerNodeType.PROPERTYELEMENT: case ScannerNodeType.EMPTYPROPERTYELEMENT: source = XamlText.TrimTrailingWhitespace(source); break; } XamlType currentPreviousChildType = this._context.CurrentPreviousChildType; if ((currentPreviousChildType == null) || currentPreviousChildType.TrimSurroundingWhitespace) { source = XamlText.TrimLeadingWhitespace(source); } if ((peekNodeType != ScannerNodeType.ELEMENT) && (peekNodeType != ScannerNodeType.EMPTYELEMENT)) { return(source); } if (this._xamlScanner.PeekType.TrimSurroundingWhitespace) { source = XamlText.TrimTrailingWhitespace(source); } } return(source); }
private string Logic_ApplyFinalTextTrimming(XamlText text) { ScannerNodeType nextNodeType = _xamlScanner.PeekNodeType; string trimmed = text.Text; if (!text.IsSpacePreserved) { // Trim trailing space from text if it is the last bit of content. // End Element and End Property Element and Start of PE all end "content" if (nextNodeType == ScannerNodeType.ENDTAG || nextNodeType == ScannerNodeType.PROPERTYELEMENT || nextNodeType == ScannerNodeType.EMPTYPROPERTYELEMENT) { trimmed = XamlText.TrimTrailingWhitespace(trimmed); } // If the text is the first thing, ie. before any element // OR the previous element was "TrimSurroundingWhitespace" // then trim leading Whitespace. XamlType previousObject = _context.CurrentPreviousChildType; if (previousObject == null || previousObject.TrimSurroundingWhitespace) { trimmed = XamlText.TrimLeadingWhitespace(trimmed); } // If next element is "TrimSurroundingWhitespace", trim trailing WS. if (nextNodeType == ScannerNodeType.ELEMENT || nextNodeType == ScannerNodeType.EMPTYELEMENT) { XamlType nextXamlType = _xamlScanner.PeekType; if (nextXamlType.TrimSurroundingWhitespace) { trimmed = XamlText.TrimTrailingWhitespace(trimmed); } } } return(trimmed); }