mirror of
https://github.com/StockSharp/StockSharp.git
synced 2026-12-04 00:21:31 +00:00
IMessageConverter and MessageConverter map FIX record structs to StockSharp messages and back. They referenced nothing but Fix.Core, yet lived in a project named Server.Protocol, so anything consuming the mapping - including a client codec - had to compile against a Server.* assembly. They now sit in Fix.Core under namespace StockSharp.Fix, next to FixOrderCondition and FixMessageTypes, which makes the wire tier Fix.Core -> codec -> connector with no server assembly in the chain. Both types become public API of the StockSharp.Fix.Core package. Fix.Core gains the two aliases the mapping needs (FixExtensions, FixTimeInForce) - inside StockSharp.Fix both Extensions and TimeInForce are ambiguous between StockSharp.Messages and StockSharp.Fix.Native. The 72 round-trip tests come along as Tests/MessageConverterTests*, and Tests takes its first reference on Fix.Core. The mass-cancel scope test asserts tag 530 on the record the converter produces instead of calling the helper that derives it, so GetMassCancelRequestType stays private and Fix.Core needs no InternalsVisibleTo beyond the one Fix.Dialects already has.
66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
namespace StockSharp.Fix;
|
|
|
|
/// <summary>
|
|
/// User message converters: UserRequest, UserRequestEx.
|
|
/// </summary>
|
|
partial class MessageConverter
|
|
{
|
|
/// <inheritdoc />
|
|
public virtual UserRequestMessage ToMessage(FixUserRequest fix)
|
|
{
|
|
var msg = new UserRequestMessage
|
|
{
|
|
TransactionId = fix.UserRequestId.ToLong(),
|
|
Login = fix.UserName,
|
|
};
|
|
|
|
if (fix.UserId != null)
|
|
msg.Id = fix.UserId;
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual FixUserRequest ToFixUserRequest(UserRequestMessage message)
|
|
{
|
|
return new FixUserRequest(
|
|
UserRequestId: FixId.FromLong(message.TransactionId),
|
|
UserRequestType: null,
|
|
UserName: message.Login,
|
|
Password: null,
|
|
NewPassword: null,
|
|
Own: null,
|
|
UserId: message.Id);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual UserLookupMessage ToMessage(FixUserRequestEx fix)
|
|
{
|
|
var msg = new UserLookupMessage
|
|
{
|
|
TransactionId = fix.UserRequestId.ToLong(),
|
|
IsSubscribe = GetIsSubscribe(fix.SubscriptionRequestType),
|
|
};
|
|
|
|
if (!fix.UserName.IsEmpty())
|
|
msg.Like = fix.UserName;
|
|
|
|
// A lookup by primary key must keep the key; dropping it turned a targeted
|
|
// user request into an unfiltered/wrong lookup after one conversion.
|
|
if (fix.Id != null)
|
|
msg.UserId = fix.Id;
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual FixUserRequestEx ToFixUserRequestEx(UserLookupMessage message)
|
|
{
|
|
return new FixUserRequestEx(
|
|
UserRequestId: FixId.FromLong(message.TransactionId),
|
|
Id: message.UserId,
|
|
UserName: message.Like,
|
|
SubscriptionRequestType: ToFixSubscriptionType(message.IsSubscribe));
|
|
}
|
|
}
|