Interface IFormattingGroup
A collection of non-conflicting formatting items that together specify a fully defined formatting or a formatting override.
Inherited Members
Namespace: Sdl.FileTypeSupport.Framework.Formatting
Assembly: Sdl.FileTypeSupport.Framework.Core.dll
Syntax
public interface IFormattingGroup : IDictionary<string, IFormattingItem>, ICollection<KeyValuePair<string, IFormattingItem>>, IEnumerable<KeyValuePair<string, IFormattingItem>>, IEnumerable, ICloneable
Remarks
Instances of this class should normally be created by calling CreateFormatting(), or by cloning an existing instance. (IFormattingItemFactory is typically accessed from the FormattingItemFactory property.)
The collection is a dictionary indexed using the FormattingName as keys for the contained formatting items.
Can be combined with other formatting by calling OverrideWith(IFormattingGroup) or UnderrideWith(IFormattingGroup).
Examples
Here is an example that shows how to explicitly turn off bold formatting only when the formatting is set:
void SetNoBold(IFormattingGroup fmt)
{
// check if there is bold formatting already
if (fmt.ContainsKey(Bold.Name))
{
// explicitly override by setting our formatting instead
Bold notBold = new Bold(false);
fmt.Add(notBold);
}
}
Properties
Item[String]
Retrieves a formatting item of a specified type.
Declaration
IFormattingItem this[string formattingName] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | formattingName |
Property Value
Type | Description |
---|---|
IFormattingItem | Null if no such formatting exists in the collection. |
Methods
Add(IFormattingItem)
Adds a formatting item to the collection. The FormattingName is used as a key. If a formatting of this type already exists, it will be replaced.
Declaration
void Add(IFormattingItem formatting)
Parameters
Type | Name | Description |
---|---|---|
IFormattingItem | formatting |
Contains(IFormattingItem)
Tests whether an equivalent formatting is part of the collection.
Declaration
bool Contains(IFormattingItem formatting)
Parameters
Type | Name | Description |
---|---|---|
IFormattingItem | formatting |
Returns
Type | Description |
---|---|
System.Boolean |
Contains(String)
Tests whether the collection contains a formatting item of a certain type.
Declaration
bool Contains(string formattingName)
Parameters
Type | Name | Description |
---|---|---|
System.String | formattingName |
Returns
Type | Description |
---|---|
System.Boolean |
OverrideWith(IFormattingGroup)
Adds each formatting item from the other object to this one, thereby overwriting any formatting of the same type in this object. Any formatting items in this object that do not have corresponding formatting items in the other object remain unchanged.
This can be used to apply a formatting override.
Declaration
void OverrideWith(IFormattingGroup otherFormatting)
Parameters
Type | Name | Description |
---|---|---|
IFormattingGroup | otherFormatting |
Remarks
Note that this operation only overrides and appends items, and thus cannot be used to explicitly remove formatting items (without overriding them).
See Also
UnderrideWith(IFormattingGroup)
Adds each formatting item from the other formatting that does not already exist in this collection.
This can be used to "overlay" formatting overrides when starting from the most significant formatting.
The difference to OverrideWith(IFormattingGroup) is the fact that existing formatting in this object is always preserved.
Declaration
void UnderrideWith(IFormattingGroup otherFormatting)
Parameters
Type | Name | Description |
---|---|---|
IFormattingGroup | otherFormatting |