/ Assembly List / LJCNetCommon / XMLBuilder

Namespace - LJCNetCommon


Syntax

C#
public class XMLBuilder

Provides methods for creating XML text.

Remarks

The XMLBuilder class is designed for creating XML text. It is similar in principle to the StringBuilder class which is designed for creating strings.

The XMLBuilder class - like the StringBuilder class - stores the text internally. The text is retrieved with the ToString() method.

Add Text Methods
The "Add" methods are similar to StringBuilder methods:
AddLine() - StringBuilder.AppendLine()
AddText() - StringBuilder.Append()
"Add" methods add text to the builder unmodified except for AddLine() which appends a newline.

Append Text Methods
Line(), Text()
"Append" methods add the potentially indented and wrapped text to the builder.
The Text() method creates the added text without an ending newline This behavior is done for consistency and it allows the developer to append to the existing text.
"Append" methods start the text with a newline if the builder already has text, param allowNewLine = true and builder text does not end with a newline.
The Line() and Text() methods should have the addIndent property set to false if it applies text retrieved with a "Get" method as the "Get" method has already applied the indent.

The AddIndent() method manually controls the current indent count. The indent string length is calculated with the properties (IndentCount * IndentCharCount) and can be retrieved with the IndentLength property.

Get Text Methods
GetLine(), GetText()
All "Get" methods create and return the potentialy indented and wrapped text but do not add it to the builder.

Append Element Methods
Begin(), Create(), End()
These methods append element tags and content. Begin() automatically increments the IndentCount by 1. Create() also increments the IndentCount by 1 if the isEmpty parameter is false and the close parameter is false. End() automatically decrements the IndentCount by 1 if the IndentCount is currently greater than zero.
The "Append" element methods create the added text without an ending newline. This behavior is done for consistency and it allows the developer to append to the existing text.
"Append" methods start the text with a newline if the builder already has text, param allowNewLine = true and builder text does not end with a newline.

Get Element Methods
GetBegin(), GetCreate(), GetEnd()
All "Get" methods create and return the potentialy indented and wrapped text but do not add it to the builder.

Constructor
#ctor Initializes an object instance.

Data
AddIndent Changes the IndentCount by the provided value.

Append Text
AddLine Adds a text line without modification.
AddText Adds text without modification.
Line Adds a modified text line to the builder.
Text Adds modified text to the builder.

Get Text
GetAttribs Gets the attributes text.
GetLine Gets a modified text line.
GetText Gets potentially indented and wrapped text.
GetIndented Gets a new potentially indented line.
GetIndentString Returns the current indent string.
GetWrapped Gets added text and new wrapped line if combined line > LineLimit.

Append Element
Begin Appends the element begin tag.
Create Appends an element.
End Missing Summary

Get Element
AddChildIndent Adds the new (child) indents.
GetBegin Gets the element begin tag.
GetCreate Gets an element.
GetEnd Gets the element end tag.

Other Public Methods
EndsWithNewLine Indicates if the builder text ends with a newline.
StartAttribs Missing Summary
ToString Retrieves the XML text.
18 Methods

Other Private Methods
StartWithNewLine Allow text to start with a newline.
5 Methods

Properties
Builder The internal StringBuilder class.
HasText Indicates if the builder has text.
IndentCharCount Gets or sets the indent character count.
IndentCount Gets or sets the current indent value.
IndentLength Gets the current indent length.
LineLength Gets the current length.
LineLimit Gets or sets the character limit.
WrapEnabled Indicates if line wrapping is enabled.

Fields
DebugText Missing Summary

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.