Dictionary Exploration
The Dictionary class exposes services to access information about the content of a specialized FIX dictionary or standard FIX messaging specification. These services allow us to obtain the types of a specific dictionary or standard FIX messages, and to explore the entire message structure, as well as to retrieve names of arbitrary fields by tag numbers.
Accessing Fields Information
To access messages and fields types information Dictionary class implements ICollection<MessageInfo> and ICollection<FieldTypeInfo> interfaces.
To access fields information MessageInfo class implements ICollection<FieldInfo>.
To access valid field values FieldTypeInfo class implements ICollection<FieldValueInfo>.
The following example demonstrates how fields, which make up a message, can be traversing:
public void TraverseMessages(Dictionary dictionary)
{
foreach (var msg in (ICollection<MessageInfo>)dictionary)
{
Console.WriteLine($"Traversing {msg.Name} (MsgType={msg.Type})...");
TraverseFields(msg.Fields, 0);
}
}
void TraverseFields(IEnumerable<FieldInfo> fields, int shift)
{
string spaces = new string(' ', shift);
foreach (var field in fields)
{
Console.WriteLine($"{spaces}{field.Name}<{field.Tag}> (required={field.IsRequired}) {field.Type?.Name}");
if (field.Type != null)
{
foreach (var value in field.Type.Values.Values)
{
Console.WriteLine($" {spaces}{value.Value} ({value.Description})");
}
}
if (field.Group != null)
TraverseFields(field.Group.Fields, 2 + shift);
}
}