# SmartFormatter

> Constructs formatted strings by invoking each registered source and formatter extension.

## Definition

* **Type:** Class
* **Namespace:** [Unity.SmartStrings](/engine/6000.7/script-reference/unity/smartstrings.md)
* **Assembly:** UnityEngine.SmartStringsModule
* **Implements:** [ISerializationCallbackReceiver](/engine/6000.7/script-reference/unityengine/iserializationcallbackreceiver.md)

```csharp
public class SmartFormatter : ISerializationCallbackReceiver
```

## Constructors

| Constructor                                                                                                                                 | Description                                           |
| ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| [SmartFormatter(Unity.SmartStrings.Core.Settings.SmartSettings)](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/ctor.md) | Creates a formatter that uses the specified settings. |

## Properties

| Property                                                                                  | Description                                                                                                                                                    |
| ----------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Parser](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/parser.md)     | The [Parser](/engine/6000.7/script-reference/unity/smartstrings/core/parsing/parser.md) this formatter uses to parse format strings.                           |
| [Settings](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/settings.md) | The [SmartSettings](/engine/6000.7/script-reference/unity/smartstrings/core/settings/smartsettings.md) that control parsing and formatting for this formatter. |

## Methods

| Method                                                                                                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [AddExtensions](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/addextensions.md)                       | Adds [IFormatter](/engine/6000.7/script-reference/unity/smartstrings/core/extensions/iformatter.md) extensions to the [SmartFormatter.GetFormatterExtensions](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/getformatterextensions.md) list of this formatter, if the Type has not been added before. Formatters are inserted at the recommended position, all others are added at the end of the list.                                                                                                                                                                                              |
| [Format](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/format.md)                                     | Replaces one or more format items in a specified string with the string representation of a specific object.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [FormatInto](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/formatinto.md)                             | Writes the formatting result into an [IOutput](/engine/6000.7/script-reference/unity/smartstrings/core/output/ioutput.md) instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [GetFormatterExtension](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/getformatterextension.md)       | Searches for a Formatter Extension of the given type, and returns it. Returns `null` if the type cannot be found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [GetFormatterExtensions](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/getformatterextensions.md)     | Gets the [IFormatter](/engine/6000.7/script-reference/unity/smartstrings/core/extensions/iformatter.md) formatter extensions registered with this formatter.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [GetSourceExtension](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/getsourceextension.md)             | Searches for a Source Extension of the given type, and returns it. Returns `null` if the type cannot be found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [GetSourceExtensions](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/getsourceextensions.md)           | Gets the [ISource](/engine/6000.7/script-reference/unity/smartstrings/core/extensions/isource.md) source extensions registered with this formatter.                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [InsertExtension](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/insertextension.md)                   | Adds the [IFormatter](/engine/6000.7/script-reference/unity/smartstrings/core/extensions/iformatter.md) extension at the `position` of the [SmartFormatter.GetFormatterExtensions](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/getformatterextensions.md) list of this formatter, if the Type has not been added before. If the extension implements [IInitializer](/engine/6000.7/script-reference/unity/smartstrings/core/extensions/iinitializer.md), [IInitializer.Initialize](/engine/6000.7/script-reference/unity/smartstrings/core/extensions/iinitializer/initialize.md) will be invoked. |
| [RemoveFormatterExtension](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/removeformatterextension.md) | Removes the Formatter Extension of the given type.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [RemoveSourceExtension](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/removesourceextension.md)       | Removes Source Extension of the given type.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

## Events

| Member                                                                                                          | Description                                    |
| --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
| [OnFormattingFailure](/engine/6000.7/script-reference/unity/smartstrings/smartformatter/onformattingfailure.md) | Raised when an error occurs during formatting. |
