From 0da7fda0c4e87e0c84bf6deacb1035528e13ec66 Mon Sep 17 00:00:00 2001 From: Ahmad Noman Musleh Date: Mon, 17 Jan 2022 12:56:39 +0300 Subject: [PATCH] Fixed an issue on GetPayloadType method --- src/Console.Sample/Program.cs | 16 ++++++++-------- .../Helpers/MessagePayloadTypeExtension.cs | 2 +- src/OpenAPI.Net/OpenAPI.Net.csproj | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Console.Sample/Program.cs b/src/Console.Sample/Program.cs index 37235a0..1863927 100644 --- a/src/Console.Sample/Program.cs +++ b/src/Console.Sample/Program.cs @@ -113,7 +113,7 @@ private static async Task Main() ClientSecret = _app.Secret, }; - await _client.SendMessage(applicationAuthReq, ProtoOAPayloadType.ProtoOaApplicationAuthReq); + await _client.SendMessage(applicationAuthReq); await Task.Delay(5000); @@ -278,7 +278,7 @@ private static async void RefreshToken() RefreshToken = _token.RefreshToken }; - await _client.SendMessage(refreshTokenReq, ProtoOAPayloadType.ProtoOaRefreshTokenReq); + await _client.SendMessage(refreshTokenReq); } private static async void SubscribeToSymbolTrendBar(string[] commandSplit) @@ -292,7 +292,7 @@ private static async void SubscribeToSymbolTrendBar(string[] commandSplit) SymbolId = long.Parse(commandSplit[4]), }; - await _client.SendMessage(subscribeLiveTrendbarReq, ProtoOAPayloadType.ProtoOaSubscribeLiveTrendbarReq); + await _client.SendMessage(subscribeLiveTrendbarReq); } private static async void SubscribeToSymbolSpot(string[] commandSplit) @@ -306,7 +306,7 @@ private static async void SubscribeToSymbolSpot(string[] commandSplit) subscribeSpotsReq.SymbolId.AddRange(commandSplit.Skip(3).Select(iSymbolId => long.Parse(iSymbolId))); - await _client.SendMessage(subscribeSpotsReq, ProtoOAPayloadType.ProtoOaSubscribeSpotsReq); + await _client.SendMessage(subscribeSpotsReq); } private static async void SymbolListRequest(string[] commandSplit) @@ -320,7 +320,7 @@ private static async void SymbolListRequest(string[] commandSplit) CtidTraderAccountId = accountId, }; - await _client.SendMessage(symbolsListReq, ProtoOAPayloadType.ProtoOaSymbolsListReq); + await _client.SendMessage(symbolsListReq); } private static async void ReconcileRequest(string[] commandSplit) @@ -334,7 +334,7 @@ private static async void ReconcileRequest(string[] commandSplit) CtidTraderAccountId = accountId, }; - await _client.SendMessage(reconcileReq, ProtoOAPayloadType.ProtoOaReconcileReq); + await _client.SendMessage(reconcileReq); } private static async void AccountListRequest() @@ -346,7 +346,7 @@ private static async void AccountListRequest() AccessToken = _token.AccessToken, }; - await _client.SendMessage(accountListByAccessTokenReq, ProtoOAPayloadType.ProtoOaGetAccountsByAccessTokenReq); + await _client.SendMessage(accountListByAccessTokenReq); } private static async void AccountAuthRequest(string[] commandSplit) @@ -361,7 +361,7 @@ private static async void AccountAuthRequest(string[] commandSplit) AccessToken = _token.AccessToken }; - await _client.SendMessage(accountAuthReq, ProtoOAPayloadType.ProtoOaAccountAuthReq); + await _client.SendMessage(accountAuthReq); } private static void GetCommand() diff --git a/src/OpenAPI.Net/Helpers/MessagePayloadTypeExtension.cs b/src/OpenAPI.Net/Helpers/MessagePayloadTypeExtension.cs index c2c5224..8df822c 100644 --- a/src/OpenAPI.Net/Helpers/MessagePayloadTypeExtension.cs +++ b/src/OpenAPI.Net/Helpers/MessagePayloadTypeExtension.cs @@ -26,7 +26,7 @@ public static uint GetPayloadType(this T message) where T : IMessage throw new InvalidOperationException($"Couldn't get the PayloadType of the message {message}", ex); } - return (uint)property.GetValue(message); + return Convert.ToUInt32(property.GetValue(message)); } } } diff --git a/src/OpenAPI.Net/OpenAPI.Net.csproj b/src/OpenAPI.Net/OpenAPI.Net.csproj index f6ef7c2..9d6ed5f 100644 --- a/src/OpenAPI.Net/OpenAPI.Net.csproj +++ b/src/OpenAPI.Net/OpenAPI.Net.csproj @@ -9,7 +9,7 @@ cTrader, Open API, Spotware A .NET RX library for Spotware Open API Spotware.OpenAPI.Net - 1.3.6-rc1 + 1.3.6-rc2 AnyCPU Spotware Spotware