Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup/nullable-ize FixValues, Session, DataDict, DataDictProvider, Message, MessageCracker, SocketSettings, SslStreamFactory #887

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
342 changes: 173 additions & 169 deletions QuickFIXn/DataDictionary/DataDictionary.cs

Large diffs are not rendered by default.

36 changes: 15 additions & 21 deletions QuickFIXn/DataDictionaryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,43 @@ namespace QuickFix
{
public class DataDictionaryProvider
{
private Dictionary<string, DataDictionary.DataDictionary> transportDataDictionaries_;
private Dictionary<string, DataDictionary.DataDictionary> applicationDataDictionaries_;
private DataDictionary.DataDictionary emptyDataDictionary_;
private readonly Dictionary<string, DataDictionary.DataDictionary> _transportDataDictionaries;
private readonly Dictionary<string, DataDictionary.DataDictionary> _applicationDataDictionaries;
private readonly DataDictionary.DataDictionary _emptyDataDictionary;

public DataDictionaryProvider()
{
transportDataDictionaries_ = new Dictionary<string, DataDictionary.DataDictionary>();
applicationDataDictionaries_ = new Dictionary<string, DataDictionary.DataDictionary>();
emptyDataDictionary_ = new DataDictionary.DataDictionary();
_transportDataDictionaries = new Dictionary<string, DataDictionary.DataDictionary>();
_applicationDataDictionaries = new Dictionary<string, DataDictionary.DataDictionary>();
_emptyDataDictionary = new DataDictionary.DataDictionary();
}

/// TODO need to make deeper copy?
public DataDictionaryProvider(DataDictionaryProvider src)
{
transportDataDictionaries_ = new Dictionary<string, DataDictionary.DataDictionary>(src.transportDataDictionaries_);
applicationDataDictionaries_ = new Dictionary<string, DataDictionary.DataDictionary>(src.applicationDataDictionaries_);
emptyDataDictionary_ = new DataDictionary.DataDictionary(src.emptyDataDictionary_);
_transportDataDictionaries = new Dictionary<string, DataDictionary.DataDictionary>(src._transportDataDictionaries);
_applicationDataDictionaries = new Dictionary<string, DataDictionary.DataDictionary>(src._applicationDataDictionaries);
_emptyDataDictionary = new DataDictionary.DataDictionary(src._emptyDataDictionary);
}

public void AddTransportDataDictionary(string beginString, DataDictionary.DataDictionary dataDictionary)
{
transportDataDictionaries_[beginString] = dataDictionary;
_transportDataDictionaries[beginString] = dataDictionary;
}

public void AddApplicationDataDictionary(string applVerID, DataDictionary.DataDictionary dataDictionary)
public void AddApplicationDataDictionary(string applVerId, DataDictionary.DataDictionary dataDictionary)
{
applicationDataDictionaries_[applVerID] = dataDictionary;
_applicationDataDictionaries[applVerId] = dataDictionary;
}

public DataDictionary.DataDictionary GetSessionDataDictionary(string beginString)
{
DataDictionary.DataDictionary dd;
if (!transportDataDictionaries_.TryGetValue(beginString, out dd))
return emptyDataDictionary_;
return dd;
return _transportDataDictionaries.GetValueOrDefault(beginString, _emptyDataDictionary);
}

public DataDictionary.DataDictionary GetApplicationDataDictionary(string applVerID)
public DataDictionary.DataDictionary GetApplicationDataDictionary(string applVerId)
{
DataDictionary.DataDictionary dd;
if (!applicationDataDictionaries_.TryGetValue(applVerID, out dd))
return emptyDataDictionary_;
return dd;
return _applicationDataDictionaries.GetValueOrDefault(applVerId, _emptyDataDictionary);
}
}
}
33 changes: 33 additions & 0 deletions QuickFIXn/FixValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace QuickFix;

public class FixValue<T> where T : notnull
{
private T _value;

public T Value => _value;
public string Description { get; }

public FixValue(T value, string description)
{
_value = value;
Description = description;
}

public override bool Equals(object? obj)
{
if (obj is null || (this.GetType() != obj.GetType()))
return false;
FixValue<T> rhs = (FixValue<T>)obj;
return this.Value.Equals(rhs.Value);
}

public override int GetHashCode()
{
return _value.GetHashCode();
}

public override string ToString()
{
return Description;
}
}
156 changes: 0 additions & 156 deletions QuickFIXn/FixValues.cs

This file was deleted.

45 changes: 45 additions & 0 deletions QuickFIXn/FixValues/ApplVerID.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace QuickFix.FixValues;

public static class ApplVerID
{
public const string FIX40 = "2";
public const string FIX41 = "3";
public const string FIX42 = "4";
public const string FIX43 = "5";
public const string FIX44 = "6";
public const string FIX50 = "7";
public const string FIX50SP1 = "8";
public const string FIX50SP2 = "9";

public static string FromBeginString(string beginString)
{
return beginString switch
{
BeginString.FIX40 => FIX40,
BeginString.FIX41 => FIX41,
BeginString.FIX42 => FIX42,
BeginString.FIX43 => FIX43,
BeginString.FIX44 => FIX44,
BeginString.FIX50 => FIX50,
BeginString.FIX50SP1 => FIX50SP1,
BeginString.FIX50SP2 => FIX50SP2,
_ => beginString
};
}

public static string ToBeginString(string applVerId) {
return applVerId switch
{
FIX40 => BeginString.FIX40,
FIX41 => BeginString.FIX41,
FIX42 => BeginString.FIX42,
FIX43 => BeginString.FIX43,
FIX44 => BeginString.FIX44,
FIX50 => BeginString.FIX50,
FIX50SP1 => BeginString.FIX50SP1,
FIX50SP2 => BeginString.FIX50SP2,
_ => throw new System.ArgumentException(
$"ApplVerId parameter '{applVerId}' does not map to a known BeginString")
};
}
}
16 changes: 16 additions & 0 deletions QuickFIXn/FixValues/BeginString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace QuickFix.FixValues;

public static class BeginString
{
// The FIX5+ beginstrings aren't legitimate, but we use them internally.

public const string FIXT11 = "FIXT.1.1";
public const string FIX50SP2 = "FIX.5.0SP2";
public const string FIX50SP1 = "FIX.5.0SP1";
public const string FIX50 = "FIX.5.0";
public const string FIX44 = "FIX.4.4";
public const string FIX43 = "FIX.4.3";
public const string FIX42 = "FIX.4.2";
public const string FIX41 = "FIX.4.1";
public const string FIX40 = "FIX.4.0";
}
18 changes: 18 additions & 0 deletions QuickFIXn/FixValues/BusinessRejectReason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.Generic;

namespace QuickFix.FixValues;

public class BusinessRejectReason
{
public static readonly Dictionary<int, string> RejText = new()
{
{ Fields.BusinessRejectReason.OTHER, "Other" },
{ Fields.BusinessRejectReason.UNKNOWN_ID, "Unknown ID" },
{ Fields.BusinessRejectReason.UNKNOWN_SECURITY, "Unknown Security" },
{ Fields.BusinessRejectReason.UNKNOWN_MESSAGE_TYPE, "Unsupported Message Type" },
{ Fields.BusinessRejectReason.APPLICATION_NOT_AVAILABLE, "Application Not Available" },
{ Fields.BusinessRejectReason.CONDITIONALLY_REQUIRED_FIELD_MISSING, "Conditionally Required Field Missing" },
{ Fields.BusinessRejectReason.NOT_AUTHORIZED, "Not authorized" },
{ Fields.BusinessRejectReason.DELIVERTO_FIRM_NOT_AVAILABLE_AT_THIS_TIME, "DeliverTo Firm Not Available At This Time" }
};
}
28 changes: 28 additions & 0 deletions QuickFIXn/FixValues/SessionRejectReason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace QuickFix.FixValues;

public class SessionRejectReason : FixValue<int>
{
public static SessionRejectReason INVALID_TAG_NUMBER = new(0, "Invalid tag number");
public static SessionRejectReason REQUIRED_TAG_MISSING = new(1, "Required tag missing");
public static SessionRejectReason TAG_NOT_DEFINED_FOR_THIS_MESSAGE_TYPE = new(2, "Tag not defined for this message type");
public static SessionRejectReason UNDEFINED_TAG = new(3, "Undefined Tag");
public static SessionRejectReason TAG_SPECIFIED_WITHOUT_A_VALUE = new(4, "Tag specified without a value");
public static SessionRejectReason VALUE_IS_INCORRECT = new(5, "Value is incorrect (out of range) for this tag");
public static SessionRejectReason INCORRECT_DATA_FORMAT_FOR_VALUE = new(6, "Incorrect data format for value");
public static SessionRejectReason DECRYPTION_PROBLEM = new(7, "Decryption problem");
public static SessionRejectReason SIGNATURE_PROBLEM = new(8, "Signature problem");
public static SessionRejectReason COMPID_PROBLEM = new(9, "CompID problem");
public static SessionRejectReason SENDING_TIME_ACCURACY_PROBLEM = new(10, "SendingTime accuracy problem");
public static SessionRejectReason INVALID_MSGTYPE = new(11, "Invalid MsgType");
public static SessionRejectReason XML_VALIDATION_ERROR = new(12, "XML validation error");
public static SessionRejectReason TAG_APPEARS_MORE_THAN_ONCE = new(13, "Tag appears more than once");
public static SessionRejectReason TAG_SPECIFIED_OUT_OF_REQUIRED_ORDER = new(14, "Tag specified out of required order");
public static SessionRejectReason REPEATING_GROUP_FIELDS_OUT_OF_ORDER = new(15, "Repeating group fields out of order");
public static SessionRejectReason INCORRECT_NUM_IN_GROUP_COUNT_FOR_REPEATING_GROUP = new(16, "Incorrect NumInGroup count for repeating group");
public static SessionRejectReason NON_DATA_VALUE_INCLUDES_FIELD_DELIMITER = new(17, "Non-data value includes field delimiter");
public static SessionRejectReason OTHER = new(99, "Other");

public SessionRejectReason(int value, string description)
: base(value, description)
{ }
}
Loading
Loading