CrystalXmlFormatters

Namespace: SnowBank.Data.Xml · class

Lexical formatters for XML scalar values

Remarks

Every form below was measured against a live DataContractSerializer and reproduces its text exactly. The two output profiles share every lexical form except Char, which is the only type with a per-profile pair (FormatDcsChar / FormatGeneralChar).

Not covered here: plain String content (written straight through WriteText) and enum labels (resolved by the generator from the declared member names, not a lexical formatting rule).

Methods

FormatBase64

static string FormatBase64(byte[] value)

Formats a byte array as base64 text

FormatBoolean

static string FormatBoolean(bool value)

Formats a Boolean as "true" or "false"

FormatByte

static string FormatByte(byte value)

Formats a Byte as invariant-culture decimal text

FormatDateTime

static string FormatDateTime(DateTime value)

Formats a DateTime using RoundtripKind: no suffix for Unspecified, a trailing Z for Utc, and the local UTC offset for Local

FormatDcsChar

static string FormatDcsChar(char value)

DCS form: the character's UTF-16 code unit as a decimal integer (e.g. 'A' -> "65")

FormatDecimal

static string FormatDecimal(decimal value)

Formats a Decimal using its XML Schema lexical form, which preserves scale (trailing zeros)

FormatDouble

static string FormatDouble(double value)

Formats a Double using its XML Schema round-trip lexical form

FormatDuration

static string FormatDuration(TimeSpan value)

Formats a TimeSpan as an ISO 8601 duration (e.g. "PT1H33M30S")

FormatGeneralChar

static string FormatGeneralChar(char value)

General form: the character itself, as a one-character string (e.g. 'A' -> "A")

FormatGuid

static string FormatGuid(Guid value)

Formats a Guid in its lowercase hyphenated lexical form

FormatInt16

static string FormatInt16(short value)

Formats a Int16 as invariant-culture decimal text

FormatInt32

static string FormatInt32(int value)

Formats an Int32 as invariant-culture decimal text

FormatInt64

static string FormatInt64(long value)

Formats a Int64 as invariant-culture decimal text

FormatSByte

static string FormatSByte(sbyte value)

Formats an SByte as invariant-culture decimal text

FormatSingle

static string FormatSingle(float value)

Formats a Single using its XML Schema round-trip lexical form

FormatUInt16

static string FormatUInt16(ushort value)

Formats a UInt16 as invariant-culture decimal text

FormatUInt32

static string FormatUInt32(uint value)

Formats a UInt32 as invariant-culture decimal text

FormatUInt64

static string FormatUInt64(ulong value)

Formats a UInt64 as invariant-culture decimal text

FormatUri

static string FormatUri(Uri value)

Formats a Uri as its raw serialization-info component text, percent-escaped by UriEscaped. XML-significant characters that a URI can still legally contain (notably &) are returned raw: escaping them into & is the emitter's job when this text is written through WriteText, not this method's.