docs.unity3d.com
    Show / Hide Table of Contents

    Class TemplateFormatter

    Template Formatter allows for registering reusable templates, and use them by name.

    Inheritance
    Object
    FormatterBase
    TemplateFormatter
    Inherited Members
    FormatterBase.Names
    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

    Default names to use when Names is null.

    Declaration
    public override string[] DefaultNames { get; }
    Property Value
    Type Description
    String[]
    Overrides
    FormatterBase.DefaultNames

    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.

    Overrides
    FormatterBase.TryEvaluateFormat(IFormattingInfo)
    In This Article
    • Constructors
      • TemplateFormatter()
    • Properties
      • DefaultNames
      • Formatter
    • Methods
      • Clear()
      • Register(String, String)
      • Remove(String)
      • TryEvaluateFormat(IFormattingInfo)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023