IFormattingExtensionsToggle
Lets a source stop formatter extensions from running for the placeholder it resolved.
Read time 1 minuteLast updated 8 days ago
Definition
- Type: Interface
- Namespace: Unity.SmartStrings.Core.Extensions
- Assembly: UnityEngine.SmartStringsModule
public interface IFormattingExtensionsToggle
Remarks
SmartFormatter passes a FormattingInfo, which implements this interface, as the ISelectorInfo argument of ISource.TryEvaluateSelector. Cast that argument to IFormattingExtensionsToggle and set IFormattingExtensionsToggle.DisableFormattingExtensions to when default formatting can't reasonably handle the value the source found. The source can then write the output itself with IFormattingInfo.Write, or write nothing.
trueAdditional Resources: ISource, FormattingInfo
Examples
using Unity.SmartStrings.Core.Extensions;// Resolves {Password} to the real value, but writes a mask instead of formatting it.public class MaskedSource : ISource{ public bool TryEvaluateSelector(ISelectorInfo selectorInfo) { if (selectorInfo.SelectorText != "Password") return false; if (selectorInfo is IFormattingExtensionsToggle toggle) toggle.DisableFormattingExtensions = true; if (selectorInfo is IFormattingInfo formattingInfo) formattingInfo.Write("********"); selectorInfo.Result = selectorInfo.CurrentValue; return true; }}
Properties
Property | Description |
|---|---|
| DisableFormattingExtensions | Gets or sets whether formatter extensions are skipped for the current placeholder. |