From 40d1d5d8d54328d1cca5ab6c39d1f5ef0fa80b0b Mon Sep 17 00:00:00 2001 From: Viacheslav Demydiuk Date: Thu, 11 Jan 2024 22:55:37 +0200 Subject: [PATCH] Updated test client for MtApi5 --- .../MtApi5TestClient/MainWindow.xaml.cs | 8 +- .../MtApi5TestClient/MtApi5TestClient.csproj | 167 ++---------------- .../Properties/AssemblyInfo.cs | 55 ------ TestClients/MtApi5TestClient/ViewModel.cs | 37 +++- 4 files changed, 54 insertions(+), 213 deletions(-) delete mode 100644 TestClients/MtApi5TestClient/Properties/AssemblyInfo.cs diff --git a/TestClients/MtApi5TestClient/MainWindow.xaml.cs b/TestClients/MtApi5TestClient/MainWindow.xaml.cs index 2239a3f9..155b7bcd 100755 --- a/TestClients/MtApi5TestClient/MainWindow.xaml.cs +++ b/TestClients/MtApi5TestClient/MainWindow.xaml.cs @@ -1,4 +1,5 @@ -using System.Text.RegularExpressions; +using System.Runtime.InteropServices; +using System.Text.RegularExpressions; using System.Windows.Input; namespace MtApi5TestClient @@ -13,6 +14,7 @@ namespace MtApi5TestClient public MainWindow() { InitializeComponent(); + AllocConsole(); Vm = new ViewModel(); _MainLayout.DataContext = Vm; @@ -28,5 +30,9 @@ namespace MtApi5TestClient var regex = new Regex("[^0-9]+"); e.Handled = regex.IsMatch(e.Text); } + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool AllocConsole(); } } diff --git a/TestClients/MtApi5TestClient/MtApi5TestClient.csproj b/TestClients/MtApi5TestClient/MtApi5TestClient.csproj index 377c8dfc..1de1ea94 100644 --- a/TestClients/MtApi5TestClient/MtApi5TestClient.csproj +++ b/TestClients/MtApi5TestClient/MtApi5TestClient.csproj @@ -1,154 +1,15 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {38B9C657-BC2F-44F0-8824-54B31F2A64F5} - WinExe - Properties - MtApi5TestClient - MtApi5TestClient - v4.5.2 - - - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - true - bin\Debug\ - DEBUG;TRACE - full - AnyCPU - bin\Debug\MtApi5TestClient.exe.CodeAnalysisLog.xml - true - GlobalSuppressions.cs - prompt - MinimumRecommendedRules.ruleset - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets - true - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules - true - false - - - bin\Release\ - TRACE - true - pdbonly - AnyCPU - bin\Release\MtApi5TestClient.exe.CodeAnalysisLog.xml - true - GlobalSuppressions.cs - prompt - MinimumRecommendedRules.ruleset - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets - true - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules - true - false - false - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - - MainWindow.xaml - Code - - - - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - {AC8B5010-DA75-477E-9CA5-547C649E12D8} - MtApi5 - - - - + + + + WinExe + net8.0-windows + enable + enable + true + + + + + + \ No newline at end of file diff --git a/TestClients/MtApi5TestClient/Properties/AssemblyInfo.cs b/TestClients/MtApi5TestClient/Properties/AssemblyInfo.cs deleted file mode 100644 index b2086a3e..00000000 --- a/TestClients/MtApi5TestClient/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MtApi5TestClient")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MtApi5TestClient")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TestClients/MtApi5TestClient/ViewModel.cs b/TestClients/MtApi5TestClient/ViewModel.cs index f7fbdd2f..67345750 100755 --- a/TestClients/MtApi5TestClient/ViewModel.cs +++ b/TestClients/MtApi5TestClient/ViewModel.cs @@ -1,17 +1,46 @@ // ReSharper disable InconsistentNaming -using System; -using System.Collections.Generic; using System.ComponentModel; using System.Windows; using MtApi5; using System.Collections.ObjectModel; using System.Globalization; -using System.Threading.Tasks; using System.IO; using Microsoft.Win32; namespace MtApi5TestClient { + class MtLogger : IMtLogger + { + public void Debug(object message) + { + Write("DEBUG", message); + } + + public void Error(object message) + { + Write("ERROR", message); + } + + public void Fatal(object message) + { + Write("FATAL", message); + } + + public void Info(object message) + { + Write("INFO", message); + } + + public void Warn(object message) + { + Write("WARN", message); + } + private void Write(string level, object message) + { + Console.WriteLine($"[{Environment.CurrentManagedThreadId}] [{level}] {message}"); + } + } + public class ViewModel : INotifyPropertyChanged { #region Commands @@ -291,7 +320,7 @@ namespace MtApi5TestClient public ViewModel() { // Init MtApi client - _mtApiClient = new MtApi5Client(); + _mtApiClient = new MtApi5Client(new MtLogger()); _mtApiClient.ConnectionStateChanged += mMtApiClient_ConnectionStateChanged; _mtApiClient.QuoteAdded += mMtApiClient_QuoteAdded;