forwardDialect Description   Table of ContentDialect Explorationforward
Session-level Dialects

The dialect examples, described above, refer to engine-wide dialects. This means that specific dialects changes will affect each Engine session with only this FIX protocol dialect. Nevertheless, sometimes there is a need to use different FIX dialects in different FIX sessions within the same engine. OnixS .NET Framework FIX Engine supports such per session dialects in the following manner.

Identifying Session-level Dialect in Dialects Description File

To focus the scope of a dialect definition from engine-wise to session level, the dialect definition must be enhanced with additional attribute id:

Example
<?xml version="1.0" encoding="utf-8"?>
<Dialect xmlns="https://ref.onixs.biz/fix/dialects"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://ref.onixs.biz/fix/dialects https://ref.onixs.biz/fix/dialects/dialects-2.18.xsd">
  <!-- Attribute 'id' tells OnixS .NET Framework FIX Engine that dialect will be used in certain sessions only. It will not be used widely. -->
  <FIX version="4.0" id="Custom FIX">
    <!-- Regular dialect description goes here. -->
  </FIX>
</Dialect>

Note Note
When the defined dialect description has non-empty id attribute, then OnixS .NET Framework FIX Engine will not use it for all sessions. Instead, such a dialect can be used for specific sessions only.
Referencing to Dialect in Session

In the source code, an instance of the Dialect class must be created. Its constructor accepts only one parameter which identifies the dialect you'd like to use for the session. Value of this parameter must be the same as in the XML description. Once an instance of Dialect is created, the FIX session can be initialized. the Session initialization is performed in the usual way with the only one difference: instead of supplying the version of the FIX protocol, the instance of the appropriate Dialect class must be passed. After that, the created session will operate using a specified FIX dialect.

Example
C#
using FIXForge.NET.FIX;

Dialect customFIX = new Dialect("Custom FIX");
Session sessionWithCustomFIX = new Session("Sender", "Target", customFIX);
VB
Imports FIXForge.NET.FIX

Dim customFIX As New Dialect("Custom FIX")
Dim sessionWithCustomFIX As New Session("Sender", "Target", customFIX)
Sending and Receiving Messages

To send messages of certain dialect, the instance of the Dialect class must be supplied during the Message construction.

An alternative way is to use the CreateMessage(String) or ParseMessage(String) members of the Dialect class. Both approaches are equivalent.

Example
C#
using FIXForge.NET.FIX;

Dialect customFIX = new Dialect("Custom FIX");

// Similar to how the Engine defines constants to certain FIX version, we
// can define our namespace, in which all custom fields and values will reside.
// Therefore, assume that CustomFIX is an example of such a namespace.
Message orderOfCustomFIX = customFIX.CreateMessage(CustomFIX.MsgType.Order_Single);

SetOrderFields(orderOfCustomFIX);
orderOfCustomFIX.Validate();

sessionWithCustomFIX.Send(orderOfCustomFIX);
VB
Imports FIXForge.NET.FIX

Dim customFIX As New Dialect("Custom FIX")

' Similar to how the Engine defines constants to certain FIX version, we
' can define our namespace in which all custom fields and values will reside.
' Therefore, assume that CustomFIX is example of such a namespace.
Dim orderOfCustomFIX As Message = customFIX.CreateMessage(CustomFIX.MsgType.Order_Single)

SetOrderFields(orderOfCustomFIX)
orderOfCustomFIX.Validate()

sessionWithCustomFIX.Send(orderOfCustomFIX)