Class SmartFormatter | Localization | 0.9.0-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Class SmartFormatter

    This class contains the Format method that constructs the composite string by invoking each extension.

    Inheritance
    Object
    SmartFormatter
    Namespace: UnityEngine.Localization.SmartFormat
    Syntax
    [Serializable]
    public class SmartFormatter

    Constructors

    SmartFormatter()

    Declaration
    public SmartFormatter()

    Properties

    FormatterExtensions

    Gets the list of IFormatter formatter extensions.

    Declaration
    public List<IFormatter> FormatterExtensions { get; }
    Property Value
    Type Description
    List<IFormatter>

    Parser

    Gets or set the instance of the Parser

    Declaration
    public Parser Parser { get; set; }
    Property Value
    Type Description
    Parser

    Settings

    Get the SmartSettings for Smart.Format

    Declaration
    public SmartSettings Settings { get; set; }
    Property Value
    Type Description
    SmartSettings

    SourceExtensions

    Gets the list of ISource source extensions.

    Declaration
    public List<ISource> SourceExtensions { get; }
    Property Value
    Type Description
    List<ISource>

    Methods

    AddExtensions(IFormatter[])

    Adds each extensions to this formatter. Each extension must implement IFormatter.

    Declaration
    public void AddExtensions(params IFormatter[] formatterExtensions)
    Parameters
    Type Name Description
    IFormatter[] formatterExtensions

    AddExtensions(ISource[])

    Adds each extensions to this formatter. Each extension must implement ISource.

    Declaration
    public void AddExtensions(params ISource[] sourceExtensions)
    Parameters
    Type Name Description
    ISource[] sourceExtensions

    Format(IFormatProvider, String, Object[])

    Replaces one or more format items in a specified string with the string representation of a specific object.

    Declaration
    public string Format(IFormatProvider provider, string format, params object[] args)
    Parameters
    Type Name Description
    IFormatProvider provider

    The IFormatProvider to use.

    String format

    A composite format string.

    Object[] args

    The object to format.

    Returns
    Type Description
    String

    Returns the formatted input with items replaced with their string representation.

    Format(String, Object[])

    Replaces one or more format items in as specified string with the string representation of a specific object.

    Declaration
    public string Format(string format, params object[] args)
    Parameters
    Type Name Description
    String format

    A composite format string.

    Object[] args

    The object to format.

    Returns
    Type Description
    String

    Returns the formatted input with items replaced with their string representation.

    Format(FormattingInfo)

    Format the FormattingInfo argument.

    Declaration
    public void Format(FormattingInfo formattingInfo)
    Parameters
    Type Name Description
    FormattingInfo formattingInfo

    FormatInto(IOutput, String, Object[])

    Writes the formatting result into an IOutput instance.

    Declaration
    public void FormatInto(IOutput output, string format, params object[] args)
    Parameters
    Type Name Description
    IOutput output

    The IOutput where the result is written to.

    String format

    The format string.

    Object[] args

    The objects to format.

    FormatWithCache(ref FormatCache, String, Object[])

    Replaces one or more format items in a specified string with the string representation of a specific object, using the FormatCache.

    Declaration
    public string FormatWithCache(ref FormatCache cache, string format, params object[] args)
    Parameters
    Type Name Description
    FormatCache cache

    The FormatCache to use.

    String format

    A composite format string.

    Object[] args

    The objects to format.

    Returns
    Type Description
    String

    Returns the formatted input with items replaced with their string representation.

    FormatWithCacheInto(ref FormatCache, IOutput, String, Object[])

    Writes the formatting result into an IOutput instance, using the FormatCache.

    Declaration
    public void FormatWithCacheInto(ref FormatCache cache, IOutput output, string format, params object[] args)
    Parameters
    Type Name Description
    FormatCache cache

    The FormatCache to use.

    IOutput output

    The IOutput where the result is written to.

    String format

    The format string.

    Object[] args

    The objects to format.

    GetFormatterExtension<T>()

    Searches for a Formatter Extension of the given type, and returns it. This can be used to easily find and configure extensions. Returns null if the type cannot be found.

    Declaration
    public T GetFormatterExtension<T>()
        where T : class, IFormatter
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    GetNotEmptyFormatterExtensionNames()

    Gets all names of registered formatter extensions which are not empty.

    Declaration
    public string[] GetNotEmptyFormatterExtensionNames()
    Returns
    Type Description
    String[]

    GetSourceExtension<T>()

    Searches for a Source Extension of the given type, and returns it. This can be used to easily find and configure extensions. Returns null if the type cannot be found.

    Declaration
    public T GetSourceExtension<T>()
        where T : class, ISource
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    Events

    OnFormattingFailure

    Event raising, if an error occurs during formatting.

    Declaration
    public event EventHandler<FormattingErrorEventArgs> OnFormattingFailure
    Event Type
    Type Description
    EventHandler<FormattingErrorEventArgs>
    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