Skip to content
axunonb edited this page May 17, 2022 · 3 revisions

General Considerations

Location

All configuration options are in namespace SmartFormat.Core.Settings.

Documentation

All settings classes have extensive xml-doc for all members. Please use xml-doc for further reference.

The main configuration container is the class SmartSettings.

SmartFormatter and Parser have a constructor which takes SmartSettings as an argument. When using the parameterless constructors, SmartSettings with its default values will be implicitly created and applied.

Important

Don't change settings after the class instance was passed as an argument.
After a "smart class" is instanciated with SmartSettings, consider the settings as immutable. Later changes to the settings may or may not take effect.

Reasoning: As long as we're supporting older .Net Frameworks, we can't implement C# 9 Init-Only properties.

// DO
var sf = new SmartFormatter(new SmartSettings { CaseSensitivity = CaseSensitivityType.CaseInsensitive });
// DO NOT
var sf = new SmartFormatter();
sf.Settings.CaseSensitivity = CaseSensitivityType.CaseInsensitive;

Overview

SmartSettings

SmartSettings have the following, most important public members. Mostly, the names are self-explanatory.

  • bool IsThreadSafeMode. Default: true
  • bool StringFormatCompatibility. Default: false
  • CaseSensitivityType CaseSensitivity. Default: CaseSensitive
  • ParserSettings Parser
    • ParseErrorAction ErrorAction. Default: ThrowError
    • bool ConvertCharacterStringLiterals. Default: true
    • bool ParseInputAsHtml. Default: false
  • FormatterSettings Formatter
    • FormatErrorAction ErrorAction. Default: ThrowError
    • char AlignmentFillCharacter. Default: ' '
  • Localization Localization
    • ILocalizationProvider? LocalizationProvider. Default: null
  • static PoolSettings Pooling
    • bool IsPoolingEnabled. Default: true
    • bool CheckReturnedObjectsExistInPool

Enums used with settings classes:

  • ParseErrorAction
    • ThrowError
    • OutputErrorInResult
    • Ignore
    • MaintainTokens
  • FormatErrorAction
    • ThrowError
    • OutputErrorInResult
    • Ignore
    • MaintainTokens
  • CaseSensitivityType
    • CaseSensitive
    • CaseInsensitive
Clone this wiki locally