Table of Contents

Class StringDecoratorExtensions

Namespace
Cuemon.Xml
Assembly
Cuemon.Xml.dll

Extension methods for the System.String class hidden behind the IDecorator<T> interface.

public static class StringDecoratorExtensions
Inheritance
Object
StringDecoratorExtensions

Methods

EscapeXml(IDecorator<String>)

Escapes the given XML of the enclosed System.String of the specified decorator.

public static string EscapeXml(this IDecorator<string> decorator)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

Returns

String

An escaped equivalent of the enclosed System.String of the specified decorator.

Exceptions

System.ArgumentNullException

decorator cannot be null.

SanitizeXmlElementName(IDecorator<String>)

Sanitizes the enclosed System.String of the specified decorator for any invalid characters.

public static string SanitizeXmlElementName(this IDecorator<string> decorator)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

Returns

String

A sanitized System.String of the enclosed System.String of the specified decorator.

Remarks

Sanitation rules are as follows:

  1. Names can contain letters, numbers, and these 4 characters: _ | : | . | -
  2. Names cannot start with a number or punctuation character
  3. Names cannot contain spaces

Exceptions

System.ArgumentNullException

decorator cannot be null.

SanitizeXmlElementText(IDecorator<String>, Boolean)

Sanitizes the enclosed System.String of the specified decorator for any invalid characters.

public static string SanitizeXmlElementText(this IDecorator<string> decorator, bool cdataSection = false)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

cdataSection Boolean

if set to true supplemental CDATA-section rules is applied to the enclosed System.String of the specified decorator.

Returns

String

A sanitized System.String of the enclosed System.String of the specified decorator.

Remarks

Sanitation rules are as follows:

  1. The enclosed System.String of the specified decorator cannot contain characters less or equal to a Unicode value of U+0019 (except U+0009, U+0010, U+0013)
  2. The enclosed System.String of the specified decorator cannot contain the string "]]<" if cdataSection is true.

Exceptions

System.ArgumentNullException

decorator cannot be null.

UnescapeXml(IDecorator<String>)

Unescapes the given XML of the enclosed System.String of the specified decorator.

public static string UnescapeXml(this IDecorator<string> decorator)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

Returns

String

An unescaped equivalent of the enclosed System.String of the specified decorator.

Exceptions

System.ArgumentNullException

decorator cannot be null.

See Also