Class SmartFormatter
This class contains the Format method that constructs the composite string by invoking each extension.
Namespace: UnityEngine.Localization.SmartFormat
Syntax
[Serializable]
public class SmartFormatter : ISerializationCallbackReceiver
Constructors
SmartFormatter()
Creates a new instance of 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 UnityEngine.Localization.SmartFormat.Core.Parsing.Parser
Declaration
public Parser Parser { get; set; }
Property Value
Type | Description |
---|---|
UnityEngine.Localization.SmartFormat.Core.Parsing.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(IList<Object>, String)
Replaces one or more format items in a specified string with the string representation of a specific object.
Declaration
public string Format(IList<object> args, string format)
Parameters
Type | Name | Description |
---|---|---|
IList<Object> | args | The list of objects to format. |
String | format | A composite format string. |
Returns
Type | Description |
---|---|
String | Returns the formatted input with items replaced with their string representation. |
Format(IFormatProvider, IList<Object>, String)
Replaces one or more format items in a specified string with the string representation of a specific object.
Declaration
public string Format(IFormatProvider provider, IList<object> args, string format)
Parameters
Type | Name | Description |
---|---|---|
IFormatProvider | provider | The IFormatProvider to use. |
IList<Object> | args | The object to format. |
String | format | A composite format string. |
Returns
Type | Description |
---|---|
String | Returns the formatted input with items replaced with their string representation. |
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 a 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 UnityEngine.Localization.SmartFormat.Core.Formatting.FormattingInfo argument.
Declaration
public virtual void Format(FormattingInfo formattingInfo)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Localization.SmartFormat.Core.Formatting.FormattingInfo | formattingInfo |
FormatInto(IOutput, String, Object[])
Writes the formatting result into an UnityEngine.Localization.SmartFormat.Core.Output.IOutput instance.
Declaration
public void FormatInto(IOutput output, string format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Localization.SmartFormat.Core.Output.IOutput | output | The UnityEngine.Localization.SmartFormat.Core.Output.IOutput where the result is written to. |
String | format | The format string. |
Object[] | args | The objects to format. |
FormatWithCache(ref FormatCache, String, IList<Object>)
Replaces one or more format items in a specified string with the string representation of a specific object, using the UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache.
Declaration
public string FormatWithCache(ref FormatCache cache, string format, IList<object> args)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache | cache | The UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache to use. |
String | format | A composite format string. |
IList<Object> | args | The objects to format. |
Returns
Type | Description |
---|---|
String | Returns the formatted input with items replaced with their string representation. |
FormatWithCache(ref FormatCache, String, IFormatProvider, IList<Object>)
Replaces one or more format items in a specified string with the string representation of a specific object, using the UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache.
Declaration
public string FormatWithCache(ref FormatCache cache, string format, IFormatProvider formatProvider, IList<object> args)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache | cache | |
String | format | |
IFormatProvider | formatProvider | |
IList<Object> | args |
Returns
Type | Description |
---|---|
String |
FormatWithCacheInto(ref FormatCache, IOutput, String, Object[])
Writes the formatting result into an UnityEngine.Localization.SmartFormat.Core.Output.IOutput instance, using the UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache.
Declaration
public void FormatWithCacheInto(ref FormatCache cache, IOutput output, string format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache | cache | The UnityEngine.Localization.SmartFormat.Core.Formatting.FormatCache to use. |
UnityEngine.Localization.SmartFormat.Core.Output.IOutput | output | The UnityEngine.Localization.SmartFormat.Core.Output.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 List<string> GetNotEmptyFormatterExtensionNames()
Returns
Type | Description |
---|---|
List<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> |