CodeText
Static class in Oadm.Sdk.Client.Controls · Oadm.Sdk.Client.dll
Detection, pretty-printing and tokenizing behind CodeView (no UI types, testable on its own). JSON and XML are re-indented with 2 spaces; text that does not parse is shown as it is, without highlighting. Texts longer than the highlight limit are shown plain (still pretty-printed up to CodeText.MaxFormatChars).
public static class CodeTextMethods
Section titled “Methods”Detect
Section titled “Detect”static CodeLanguage Detect(string? text, string? contentType = null)Language from the content type (“application/json”, “text/xml”, “application/soap+xml”), else from the text itself.
FormatJson
Section titled “FormatJson”static string? FormatJson(string text)JSON indented with 2 spaces and LF line ends (non-ASCII kept readable), or null when it does not parse.
FormatXml
Section titled “FormatXml”static string? FormatXml(string text)XML (also SOAP) indented with 2 spaces and LF line ends, declaration kept, or null when it does not parse. DTDs are refused.
Prepare
Section titled “Prepare”static CodeDocument Prepare(string? text, CodeLanguage language = Auto, string? contentType = null, bool format = true, int highlightLimit = 524288, bool colorUnparsed = false)Prepares text for display. format false keeps the text exactly as it is (still highlighted when it parses). colorUnparsed: JSON and XML that do not parse are still colored token by token (the code editor while typing, an HTML body with several elements). Never throws for any input.
Tokenize
Section titled “Tokenize”static IReadOnlyList<CodeToken> Tokenize(string text, CodeLanguage language)Tokens of text; adjacent tokens of the same kind separated only by white space are merged.
Fields
Section titled “Fields”DefaultHighlightLimit
Section titled “DefaultHighlightLimit”const int DefaultHighlightLimit = 524288Default highlight limit: above it the text is shown without colors (keeps the view fast).
MaxFormatChars
Section titled “MaxFormatChars”const int MaxFormatChars = 4194304Above this size JSON and XML are not re-indented either.