• Version 1.15.2
Show / Hide Table of Contents

Class Message

FIX message.

Inheritance
object
FieldSet
Message
Implements
IDisposable
IMessage
IFieldSet
IEnumerable<Field>
IEnumerable
Inherited Members
FieldSet.Init(Message, FieldContainerInfo)
FieldSet.Init(Message, FieldSet)
FieldSet.NumberOfFields
FieldSet.GetFields()
FieldSet.AddField()
FieldSet.NumberOfGroups
FieldSet.InitGroup(FieldInfo)
FieldSet.GetGroupByPsn(int)
FieldSet.Contains(int)
FieldSet.IsAbsentOrEmpty(int)
FieldSet.Contains(int, bool)
FieldSet.this[int]
FieldSet.GetChar(int)
FieldSet.TryGetChar(int, out char)
FieldSet.Set(int, char)
FieldSet.GetInteger(int)
FieldSet.TryGetInteger(int, out int)
FieldSet.Set(int, int)
FieldSet.GetUInteger(int)
FieldSet.TryGetUInteger(int, out uint)
FieldSet.Set(int, uint)
FieldSet.GetLong(int)
FieldSet.TryGetLong(int, out long)
FieldSet.Set(int, long)
FieldSet.GetULong(int)
FieldSet.TryGetULong(int, out ulong)
FieldSet.Set(int, ulong)
FieldSet.GetDouble(int)
FieldSet.TryGetDouble(int, out double)
FieldSet.Set(int, double)
FieldSet.Set(int, double, int)
FieldSet.GetDecimal(int)
FieldSet.TryGetDecimal(int, out decimal)
FieldSet.Set(int, decimal)
FieldSet.Set(int, decimal, int)
FieldSet.TryGetTimestamp(int, out DateTime)
FieldSet.TryGetTimestamp(int, out DateTime, out TimestampFormat)
FieldSet.TryGetTimeSpan(int, out TimeSpan)
FieldSet.TryGetTimeSpan(int, out TimeSpan, out TimeSpanFormat)
FieldSet.TryGetHighResolutionTimestamp(int, out HighResolutionTimestamp)
FieldSet.TryGetHighResolutionTimestamp(int, out HighResolutionTimestamp, out TimestampFormat)
FieldSet.TryGetHighResolutionTimeSpan(int, out HighResolutionTimeSpan)
FieldSet.TryGetHighResolutionTimeSpan(int, out HighResolutionTimeSpan, out TimeSpanFormat)
FieldSet.GetTimestamp(int)
FieldSet.GetTimestamp(int, out TimestampFormat)
FieldSet.GetTimeSpan(int)
FieldSet.GetTimeSpan(int, out TimeSpanFormat)
FieldSet.GetHighResolutionTimestamp(int)
FieldSet.GetHighResolutionTimestamp(int, out TimestampFormat)
FieldSet.GetHighResolutionTimeSpan(int)
FieldSet.GetHighResolutionTimeSpan(int, out TimeSpanFormat)
FieldSet.Set(int, DateTime, TimestampFormat)
FieldSet.Set(int, DateTime)
FieldSet.Set(int, TimeSpan, TimeSpanFormat)
FieldSet.Set(int, TimeSpan)
FieldSet.Set(int, in HighResolutionTimestamp, TimestampFormat)
FieldSet.Set(int, in HighResolutionTimestamp)
FieldSet.Set(int, in HighResolutionTimeSpan, TimeSpanFormat)
FieldSet.Set(int, in HighResolutionTimeSpan)
FieldSet.Get(int)
FieldSet.TryGet(int, out string)
FieldSet.GetSpan(int)
FieldSet.TryGetSpan(int, out ReadOnlySpan<byte>)
FieldSet.GetBytes(int)
FieldSet.TryGetBytes(int, out byte[])
FieldSet.Set(int, byte[])
FieldSet.GetFlag(int)
FieldSet.TryGetFlag(int, out bool)
FieldSet.SetFlag(int, bool)
FieldSet.Set(int, bool)
FieldSet.HasGroup(int)
FieldSet.GetGroup(int)
FieldSet.TryGetGroup(int, out Group)
FieldSet.SetGroup(int, int)
FieldSet.FieldCount
FieldSet.ToRawFixString()
FieldSet.ToString()
FieldSet.ToString(char, FixStringFormat)
FieldSet.ToString(FixStringFormat)
FieldSet.GetGroupsEnumerator()
FieldSet.GetEnumerator()
FieldSet.CompareFieldValue(int, string)
FieldSet.Get(int, StringBuilder)
FieldSet.TryGet(int, StringBuilder)
FieldSet.EnsureNotDisposed()
FieldSet.IsDisposed
FieldSet.Dispose()
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: OnixS.Fix
Assembly: OnixS.Fix.Engine.dll
Syntax
public class Message : FieldSet, IDisposable, IMessage, IFieldSet, IEnumerable<Field>, IEnumerable

Constructors

Message(Message, MessageMemoryPool)

Creates the exact copy of the given message.

Declaration
public Message(Message message, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
Message message

Source message to copy

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Exceptions
Type Condition
NullReferenceException

if message == null

Message(string, IMessageInfoDictionary, int, MessageMemoryPool)

Creates a message of the specified type.

Declaration
public Message(string messageType, IMessageInfoDictionary dictionary, int contentsCapacity = 128, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
string messageType

Message type (the MsgType (tag 35) field value)

IMessageInfoDictionary dictionary

Dictionary to be used during the message construction

int contentsCapacity

size of buffer to store message field value

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Message(string, ProtocolVersion, int, MessageMemoryPool)

Creates a message of the specified type.

Declaration
public Message(string messageType, ProtocolVersion version, int contentsCapacity = 128, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
string messageType

Message type (the MsgType (tag 35) field value)

ProtocolVersion version

FIX Protocol version to be used during the message construction

int contentsCapacity

size of buffer to store message field value

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Properties

Dictionary

Dictionary that was used to construct the message.

Declaration
public IMessageInfoDictionary Dictionary { get; }
Property Value
Type Description
IMessageInfoDictionary

IsFlatMessage

Returns true if this is a FlatMessage instance, otherwise - false.

Declaration
public bool IsFlatMessage { get; }
Property Value
Type Description
bool

true if this is a FlatMessage instance, otherwise - false

Name

Message name.

Declaration
public string Name { get; }
Property Value
Type Description
string

Message name

SenderCompId

Assigned value used to identify firm sending message (the SenderCompID (tag=49) field value).

Declaration
public string SenderCompId { get; set; }
Property Value
Type Description
string

SenderCompID

SeqNum

Message sequence number (the MsgSeqNum (tag=34) field value).

Declaration
public int SeqNum { get; set; }
Property Value
Type Description
int

Message sequence number

TargetCompId

Assigned value used to identify receiving firm (the TargetCompID (tag=56) field value).

Declaration
public string TargetCompId { get; set; }
Property Value
Type Description
string

TargetCompID

Type

Returns message type (the MsgType (tag=35) field value).

Declaration
public string Type { get; }
Property Value
Type Description
string

message type

Version

Financial Interface eXchange (FIX) protocol version.

Declaration
public ProtocolVersion Version { get; }
Property Value
Type Description
ProtocolVersion

The FIX protocol version of the message

Methods

Assemble(ByteBuffer)

Declaration
public override void Assemble(ByteBuffer bb)
Parameters
Type Name Description
ByteBuffer bb
Overrides
FieldSet.Assemble(ByteBuffer)

Clone()

Declaration
public Message Clone()
Returns
Type Description
Message

CompareType(char)

Returns true if the message type value is equal to the given char value, otherwise it returns false. The method can help to write GC-free code.

Declaration
public bool CompareType(char type)
Parameters
Type Name Description
char type

Message type to compare

Returns
Type Description
bool

True if the message type value is equal to the given string value

CompareType(string)

Returns true if the message type value is equal to the given string value, otherwise it returns false. The method can help to write GC-free code.

Declaration
public bool CompareType(string type)
Parameters
Type Name Description
string type

Message type to compare

Returns
Type Description
bool

True if the message type value is equal to the given string value

CopyFields(Message)

Copies all fields except the protocol version and message type from the given message.

Declaration
public void CopyFields(Message source)
Parameters
Type Name Description
Message source

The source Message instance

Equals(object)

Determines whether the specified object is equal to the current object.

Declaration
public override bool Equals(object o)
Parameters
Type Name Description
object o
Returns
Type Description
bool

true if the specified object is equal to the current object; otherwise, false.

Overrides
object.Equals(object)

GetEnumeratorOverRawMsg()

Returns an iterator over a raw FIX message as set of fields.

Note: Before any modifications to a FIX message the set of fields will be in the same order as they are received/parsed and will include duplicates.

Declaration
public virtual IEnumerator<Field> GetEnumeratorOverRawMsg()
Returns
Type Description
IEnumerator<Field>

an Iterator.

GetHashCode()

Serves as the default hash function.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for the current object.

Overrides
object.GetHashCode()

GetMessage()

Declaration
protected override Message GetMessage()
Returns
Type Description
Message
Overrides
FieldSet.GetMessage()

GetPosition(int)

Declaration
protected override int GetPosition(int tag)
Parameters
Type Name Description
int tag
Returns
Type Description
int
Overrides
FieldSet.GetPosition(int)

GetStructuredMessage(IMessageInfoDictionary, MessageValidationFlags)

Returns the Message instance create from the given FlatMessage.

Declaration
public Message GetStructuredMessage(IMessageInfoDictionary dictionary, MessageValidationFlags messageParsingFlags)
Parameters
Type Name Description
IMessageInfoDictionary dictionary

Dictionary to be used during the Message creation

MessageValidationFlags messageParsingFlags
Returns
Type Description
Message

Message instance

Init(Message)

Initializes the message.

Declaration
public void Init(Message message)
Parameters
Type Name Description
Message message

source FIX message to copy

Exceptions
Type Condition
NullReferenceException

if message == null

Init(ReadOnlySpan<byte>, MessageValidationFlags)

Initializes the message.

Declaration
public void Init(ReadOnlySpan<byte> rawMsg, MessageValidationFlags parsingFlags = MessageValidationFlags.None)
Parameters
Type Name Description
ReadOnlySpan<byte> rawMsg

Raw FIX message in the tag=value form

MessageValidationFlags parsingFlags

Parsing flags

Init(string, MessageValidationFlags)

Initializes the message.

Declaration
public void Init(string rawMessage, MessageValidationFlags parsingFlags = MessageValidationFlags.None)
Parameters
Type Name Description
string rawMessage

Raw FIX message in the tag=value form

MessageValidationFlags parsingFlags

Parsing flags

IsSessionLevel()

Returns true if this is a session-level message, otherwise - false.

Declaration
public bool IsSessionLevel()
Returns
Type Description
bool

true if this is a session-level message, otherwise - false

Parse(FlatMessage, MessageInfoDictionaryManager, MessageValidationFlags, MessageMemoryPool)

Creates a Message instance on the base of the given FlatMessage object.

Declaration
public static Message Parse(FlatMessage flatMessage, MessageInfoDictionaryManager dictionaryManager, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
FlatMessage flatMessage

Source FlatMessage

MessageInfoDictionaryManager dictionaryManager

MessageInfoDictionaryManager to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message

Parse(FlatMessage, IMessageInfoDictionary, MessageValidationFlags, MessageMemoryPool)

Creates a Message instance on the base of the given FlatMessage object.

Declaration
public static Message Parse(FlatMessage flatMessage, IMessageInfoDictionary dictionary, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
FlatMessage flatMessage

Source FlatMessage

IMessageInfoDictionary dictionary

Dictionary to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message

Parse(byte[], int, int, MessageInfoDictionaryManager, MessageValidationFlags, MessageMemoryPool)

Parses the byte array and creates the corresponding message.

Declaration
public static Message Parse(byte[] rawMessage, int offset, int length, MessageInfoDictionaryManager dictionaryManager, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
byte[] rawMessage

FIX message in the tag=value form

int offset

message offset

int length

message length in bytes

MessageInfoDictionaryManager dictionaryManager

MessageInfoDictionaryManager to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message
Exceptions
Type Condition
NullReferenceException

if rawMsg == null

Parse(byte[], int, int, IMessageInfoDictionary, MessageValidationFlags, MessageMemoryPool)

Parses the byte array and creates the corresponding message.

Declaration
public static Message Parse(byte[] rawMessage, int offset, int length, IMessageInfoDictionary dictionary, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
byte[] rawMessage

FIX message in the tag=value form

int offset

message offset

int length

message length in bytes

IMessageInfoDictionary dictionary

Dictionary to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message

Parse(ReadOnlySpan<byte>, MessageInfoDictionaryManager, MessageValidationFlags, MessageMemoryPool)

Parses the byte span and creates the corresponding message instance.

Declaration
public static Message Parse(ReadOnlySpan<byte> rawMessage, MessageInfoDictionaryManager dictionaryManager, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
ReadOnlySpan<byte> rawMessage

FIX message in the tag=value form

MessageInfoDictionaryManager dictionaryManager

MessageInfoDictionaryManager to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message
Exceptions
Type Condition
NullReferenceException

if rawMessage == null

Parse(ReadOnlySpan<byte>, IMessageInfoDictionary, MessageValidationFlags, MessageMemoryPool)

Parses the byte span and creates the corresponding message instance.

Declaration
public static Message Parse(ReadOnlySpan<byte> rawMessage, IMessageInfoDictionary dictionary, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
ReadOnlySpan<byte> rawMessage

raw FIX message in the tag=value form

IMessageInfoDictionary dictionary

Dictionary to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message
Exceptions
Type Condition
NullReferenceException

if rawMessage == null

Parse(string, MessageInfoDictionaryManager, MessageValidationFlags, MessageMemoryPool)

Parses the raw FIX message string and creates the corresponding message.

Declaration
public static Message Parse(string rawMessage, MessageInfoDictionaryManager dictionaryManager, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
string rawMessage

raw FIX message in the tag=value form

MessageInfoDictionaryManager dictionaryManager

MessageInfoDictionaryManager to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message
Exceptions
Type Condition
NullReferenceException

if rawMessage == null

Parse(string, IMessageInfoDictionary, MessageValidationFlags, MessageMemoryPool)

Parses the string and creates the corresponding message.

Declaration
public static Message Parse(string rawMessage, IMessageInfoDictionary dictionary, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
string rawMessage

FIX message in the tag=value form

IMessageInfoDictionary dictionary

Dictionary to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message
Exceptions
Type Condition
NullReferenceException

if rawMessage == null

Parse(string, MessageValidationFlags, MessageMemoryPool)

Parses the string and creates the corresponding message.

Declaration
public static Message Parse(string rawMessage, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
string rawMessage

FIX message in the tag=value form

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message
Exceptions
Type Condition
NullReferenceException

if rawMessage == null

Parse(string, ProtocolVersion, MessageValidationFlags, MessageMemoryPool)

Parses the string and creates the corresponding message.

Declaration
public static Message Parse(string rawMessage, ProtocolVersion version, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type Name Description
string rawMessage

FIX message in the tag=value form

ProtocolVersion version

ProtocolVersion to be used during the message construction

MessageValidationFlags parsingFlags

Parsing flags

MessageMemoryPool memoryPool

memory pool for pre-allocated objects

Returns
Type Description
Message
Exceptions
Type Condition
NullReferenceException

if rawMessage == null

Remove(int)

Removes the field.

Declaration
public override bool Remove(int tag)
Parameters
Type Name Description
int tag

Tag number

Returns
Type Description
bool

true If the field was found and removed, otherwise false

Overrides
FieldSet.Remove(int)

Reset()

Resets to the clean, non-initialized state.

Declaration
public void Reset()

Set(int, byte[], int, int)

Sets the byte[] value.

Declaration
public override IFieldSet Set(int tag, byte[] value, int offset, int length)
Parameters
Type Name Description
int tag

Tag number

byte[] value

Field value

int offset

Value offset

int length

Value length

Returns
Type Description
IFieldSet

This instance

Overrides
FieldSet.Set(int, byte[], int, int)
Exceptions
Type Condition
TagNotDefinedForThisMessageTypeException

if field with the given tag is not defined for this message and unknown fields are disabled

ArgumentException

(offset < 0) or (offset + length > value.length) or (length < 0)

Set(int, ReadOnlySpan<byte>)

Sets the ReadOnlySpan<T> value.

Declaration
public override IFieldSet Set(int tag, ReadOnlySpan<byte> value)
Parameters
Type Name Description
int tag

Tag number

ReadOnlySpan<byte> value

Field value

Returns
Type Description
IFieldSet

This instance

Overrides
FieldSet.Set(int, ReadOnlySpan<byte>)
Exceptions
Type Condition
TagNotDefinedForThisMessageTypeException

if field with the given tag is not defined for this message and unknown fields are disabled

Set(int, string)

Sets the string value.

Declaration
public override IFieldSet Set(int tag, string value)
Parameters
Type Name Description
int tag

Tag number

string value

Field value

Returns
Type Description
IFieldSet

This instance

Overrides
FieldSet.Set(int, string)
Exceptions
Type Condition
TagNotDefinedForThisMessageTypeException

if field with the given tag is not defined for this message and unknown fields are disabled

Set(int, StringBuilder)

Sets the string value.

Declaration
public override IFieldSet Set(int tag, StringBuilder value)
Parameters
Type Name Description
int tag

Tag number

StringBuilder value

Field value

Returns
Type Description
IFieldSet

This instance

Overrides
FieldSet.Set(int, StringBuilder)
Exceptions
Type Condition
TagNotDefinedForThisMessageTypeException

if field with the given tag is not defined for this message and unknown fields are disabled

ToBytes(Span<byte>)

Serializes the message to the given byte span.

Declaration
public int ToBytes(Span<byte> buffer)
Parameters
Type Name Description
Span<byte> buffer

Byte span to serialize the message content to

Returns
Type Description
int

The number of copied bytes if the given span is large enough; otherwise - a negative number, the absolute value of which is equal to the required size of the span

ToJson(string, string)

Returns the JSON representation.

Declaration
public string ToJson(string indent = "  ", string endOfLineDelimiter = "\n")
Parameters
Type Name Description
string indent
string endOfLineDelimiter
Returns
Type Description
string

JSON representation

Remarks

For custom fields, a name is created by combining the Tag prefix with the tag number.

ToXml(string, string)

Returns the XML representation.

Declaration
public string ToXml(string indent = "  ", string endOfLineDelimiter = "\n")
Parameters
Type Name Description
string indent
string endOfLineDelimiter
Returns
Type Description
string

XML representation

Remarks

For custom fields, a name is created by combining the Tag prefix with the tag number.

UpdateBodyLengthAndCheckSum()

Updates the BodyLength (tag 9) and CheckSum (tag 10) fields.

Declaration
public void UpdateBodyLengthAndCheckSum()

Validate(MessageValidationFlags)

Validates the message.

Declaration
public void Validate(MessageValidationFlags validationFlags = MessageValidationFlags.StrictCreated)
Parameters
Type Name Description
MessageValidationFlags validationFlags

Validation flags

Exceptions
Type Condition
ParserException

if the message is not valid

Implements

IDisposable
IMessage
IFieldSet
IEnumerable<T>
IEnumerable
In this article
Back to top Copyright © Onix Solutions.
Generated by DocFX