Class TemplateFormatter
Template Formatter allows for registering reusable templates, and use them by name.
Inherited Members
Namespace: UnityEngine.Localization.SmartFormat.Extensions
Syntax
[Serializable]
public class TemplateFormatter : FormatterBase, IFormatter, ISerializationCallbackReceiver
Constructors
TemplateFormatter()
Creates a new instance of the formatter.
Declaration
public TemplateFormatter()
Properties
DefaultNames
Declaration
public override string[] DefaultNames { get; }
Property Value
Type | Description |
---|---|
String[] |
Overrides
Formatter
The SmartFormatter that the formatter is part of.
Declaration
public SmartFormatter Formatter { get; set; }
Property Value
Type | Description |
---|---|
SmartFormatter |
Methods
Clear()
Remove all templates.
Declaration
public void Clear()
Register(String, String)
Register a new template.
Declaration
public void Register(string templateName, string template)
Parameters
Type | Name | Description |
---|---|---|
String | templateName | A name for the template, which is not already registered. |
String | template | The string to be used as a template. |
Remove(String)
Remove a template by its name.
Declaration
public bool Remove(string templateName)
Parameters
Type | Name | Description |
---|---|---|
String | templateName |
Returns
Type | Description |
---|---|
Boolean |
TryEvaluateFormat(IFormattingInfo)
This method is called by the SmartFormatter to obtain the formatting result of this extension.
Declaration
public override bool TryEvaluateFormat(IFormattingInfo formattingInfo)
Parameters
Type | Name | Description |
---|---|---|
IFormattingInfo | formattingInfo |
Returns
Type | Description |
---|---|
Boolean | Returns true if successful, else false. |