| IFormattingItem Interface |
Namespace: Sdl.FileTypeSupport.Framework.Formatting
The IFormattingItem type exposes the following members.
| Name | Description | |
|---|---|---|
| FormattingName |
The name of this type of formatting.
The name may be used as an attribute name when storing this particular formatting in XML format, in which case the value of the attribute represents the StringValue property. | |
| LocalizedFormattingName |
A localized representation of the formatting name. This can be used
when displaying the formatting in a client UI.
| |
| LocalizedStringValue |
A localized representation of the formatting value. This can be used
when displaying the formatting value in a client UI.
| |
| StringValue |
The value this formatting represents as a string.
Formatting classes should allow their entire value to be
retrieved and set through this property.
The name and string value may be used for storing the formatting as an XML attribute with a value. |
| Name | Description | |
|---|---|---|
| AcceptVisitor |
Implementation of the visitor pattern for formatting items
|
Examples of formatting items include Bold and FontSize.
The formatting property is effectively a key/value pair, in which the FormattingName acts as a key describing the formatting property type (e.g. "Bold"), and the StringValue represents the value associated with the formatting type (e.g. "On"). Implementation classes typically provide convenience accessors that can be used to set the string value using strong types (e.g. color or bool). However, the actual value should also be accessible and settable via the StringValue property.
Formatting items are serialized as a key/value pair using the FormattingName and StringValue properties. They can be de-serialized from a string key/value pair by calling CreateFormattingItem(String, String).
Formatting items are typically instantiated directly (e.g. new Bold()), and assigned to an IFormattingGroup instance.
If the formatting needs to be shown in text form to the user, the LocalizedFormattingName and LocalizedStringValue properties should be used. Implementation classes should return culture specific values for these properties as appropriate.
This interface also implements a visitor pattern (via AcceptVisitor(IFormattingVisitor)) that can be used by applications to discover the well-known formatting item types defined in IFormattingVisitor.
To represent formatting types other than the well-known ones, which are listed in the IFormattingVisitor interface, you can either use an explicit instance of UnknownFormatting (e.g. new UnknownFormatting("Emboss", "On")), or derive your own implementation class from this type. (If you derive your own implementation, you may also want to provide your own implementation of the IFormattingItemFactory to ensure that formatting items are correctly de-serialized to your implementation class. Given the complexities of this approach, it is typically preferred to use an explicit UnknownFormatting instance.)