forked from vdemydiuk/mtapi
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added .net core based MtApiService * based on https://github.com/dotnet/wcf * only client side is available in .net core * piping removed, only tcp connection possible * ported MtApi5 and MtApi5TestClient to .net core * updated dependencies and moved to .net5.0 * removed build warning
- Loading branch information
Showing
14 changed files
with
541 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="ILMerge" version="2.13.0307" targetFramework="net40" /> | ||
<package id="log4net" version="2.0.10" targetFramework="net40" /> | ||
<package id="log4net" version="2.0.12" targetFramework="net40" /> | ||
<package id="MSBuild.ILMerge.Task" version="1.0.5" targetFramework="net40" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{AC8B5010-DA75-477E-9CA5-547C649E12D8}</ProjectGuid> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>MtApi5</RootNamespace> | ||
<AssemblyName>MtApi5</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\build\products\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>..\build\products\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net40\Newtonsoft.Json.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Configuration.Install" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.ServiceModel" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<ProjectReference Include="..\MtApiServiceNetCore\MtApiServiceNetCore.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="CopyTicksFlag.cs" /> | ||
<Compile Include="Events\OnBookEvent.cs" /> | ||
<Compile Include="Events\OnLastTimeBarEvent.cs" /> | ||
<Compile Include="Events\OnLockTicksEvent.cs" /> | ||
<Compile Include="Events\OnTickEvent.cs" /> | ||
<Compile Include="Events\OnTradeTransactionEvent.cs" /> | ||
<Compile Include="Mt5LockTicksEventArgs.cs" /> | ||
<Compile Include="Mt5TimeBarArgs.cs" /> | ||
<Compile Include="MqlBookInfo.cs" /> | ||
<Compile Include="MqlParam.cs" /> | ||
<Compile Include="MqlRates.cs" /> | ||
<Compile Include="MqlTick.cs" /> | ||
<Compile Include="MqlTradeCheckResult.cs" /> | ||
<Compile Include="MqlTradeTransaction.cs" /> | ||
<Compile Include="Mt5BookEventArgs.cs" /> | ||
<Compile Include="Mt5TimeConverter.cs" /> | ||
<Compile Include="Mt5Enums.cs" /> | ||
<Compile Include="Mt5ConnectionEventArgs.cs" /> | ||
<Compile Include="Mt5ConnectionState.cs" /> | ||
<Compile Include="MqlTradeRequest.cs" /> | ||
<Compile Include="MqlTradeResult.cs" /> | ||
<Compile Include="Mt5QuoteEventArgs.cs" /> | ||
<Compile Include="Mt5TradeTransactionEventArgs.cs" /> | ||
<Compile Include="MtApi5Client.cs" /> | ||
<Compile Include="Mt5CommandType.cs" /> | ||
<Compile Include="MtConverters.cs" /> | ||
<Compile Include="ErrorCode.cs" /> | ||
<Compile Include="ExecutionException.cs" /> | ||
<Compile Include="Events\Mt5EventTypes.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Mt5Quote.cs" /> | ||
<Compile Include="Requests\BuyRequest.cs" /> | ||
<Compile Include="Requests\ChartTimePriceToXyRequest.cs" /> | ||
<Compile Include="Requests\ChartTimePriceToXyResult.cs" /> | ||
<Compile Include="Requests\ChartXyToTimePriceRequest.cs" /> | ||
<Compile Include="Requests\ChartXyToTimePriceResult.cs" /> | ||
<Compile Include="Requests\CopyTicksRequest.cs" /> | ||
<Compile Include="Requests\ICustomRequest.cs" /> | ||
<Compile Include="Requests\IndicatorCreateRequest.cs" /> | ||
<Compile Include="Requests\MarketBookGetRequest.cs" /> | ||
<Compile Include="Requests\OrderCheckRequest.cs" /> | ||
<Compile Include="Requests\OrderCheckResult.cs" /> | ||
<Compile Include="Requests\OrderSendAsyncRequest.cs" /> | ||
<Compile Include="Requests\OrderSendRequest.cs" /> | ||
<Compile Include="Requests\PositionCloseRequest.cs" /> | ||
<Compile Include="Requests\PositionCloseResult.cs" /> | ||
<Compile Include="Requests\PositionOpenRequest.cs" /> | ||
<Compile Include="Requests\RequestBase.cs" /> | ||
<Compile Include="Requests\RequestType.cs" /> | ||
<Compile Include="Requests\OrderSendResult.cs" /> | ||
<Compile Include="Requests\Response.cs" /> | ||
<Compile Include="Requests\SellRequest.cs" /> | ||
<Compile Include="Requests\SymbolInfoStringRequest.cs" /> | ||
<Compile Include="Requests\SymbolInfoStringResult.cs" /> | ||
<Compile Include="Requests\SymbolInfoTickRequest.cs" /> | ||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\MTApiService\MTApiService.csproj"> | ||
<Project>{DE76D5C7-B99C-4467-8408-78173BDD84E0}</Project> | ||
<Name>MTApiService</Name> | ||
</ProjectReference> | ||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net40" /> | ||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Channels; | ||
|
||
namespace MTApiService | ||
{ | ||
internal class MtApiProxy : IMtApi, IDisposable | ||
{ | ||
private IMtApi InnerChannel; | ||
|
||
public CommunicationState State => ((ICommunicationObject)InnerChannel).State; | ||
|
||
public MtApiProxy(InstanceContext callbackContext, Binding binding, EndpointAddress remoteAddress) | ||
{ | ||
var channel = new DuplexChannelFactory<IMtApi>(callbackContext, binding, remoteAddress); | ||
channel.Faulted += InnerDuplexChannel_Faulted; | ||
|
||
// configure endpoint programmatically instead via an attribute which will lead to a PlatformNotSupportedException | ||
(channel.Endpoint.EndpointBehaviors.Single(b => b is CallbackBehaviorAttribute) as CallbackBehaviorAttribute).UseSynchronizationContext = false; | ||
|
||
InnerChannel = channel.CreateChannel(); | ||
} | ||
|
||
#region IMtApi Members | ||
|
||
public bool Connect() | ||
{ | ||
return InnerChannel.Connect(); | ||
} | ||
|
||
public void Disconnect() | ||
{ | ||
InnerChannel.Disconnect(); | ||
} | ||
|
||
public MtResponse SendCommand(MtCommand command) | ||
{ | ||
return InnerChannel.SendCommand(command); | ||
} | ||
|
||
public List<MtQuote> GetQuotes() | ||
{ | ||
return InnerChannel.GetQuotes(); | ||
} | ||
|
||
#endregion | ||
|
||
#region IDisposable Members | ||
|
||
public void Dispose() | ||
{ | ||
try | ||
{ | ||
Disconnect(); | ||
} | ||
catch (Exception) | ||
{ | ||
|
||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Private Methods | ||
private void InnerDuplexChannel_Faulted(object sender, EventArgs e) | ||
{ | ||
Faulted?.Invoke(this, e); | ||
} | ||
|
||
#endregion | ||
|
||
#region Events | ||
public event EventHandler Faulted; | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<OutputPath>..\build\products\Debug\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<OutputPath>..\build\products\Release\</OutputPath> | ||
<DefineConstants></DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="..\MTApiService\IMetaTraderHandler.cs" Link="IMetaTraderHandler.cs" /> | ||
<Compile Include="..\MTApiService\ITaskExecutor.cs" Link="ITaskExecutor.cs" /> | ||
<Compile Include="..\MTApiService\LogConfigurator.cs" Link="LogConfigurator.cs" /> | ||
<Compile Include="..\MTApiService\Mt5Expert.cs" Link="Mt5Expert.cs" /> | ||
<Compile Include="..\MTApiService\MtCommand.cs" Link="MtCommand.cs" /> | ||
<Compile Include="..\MTApiService\MtCommandEventArgs.cs" Link="MtCommandEventArgs.cs" /> | ||
<Compile Include="..\MTApiService\MtCommandTask.cs" Link="MtCommandTask.cs" /> | ||
<Compile Include="..\MTApiService\MtEvent.cs" Link="MtEvent.cs" /> | ||
<Compile Include="..\MTApiService\MtExpert.cs" Link="MtExpert.cs" /> | ||
<Compile Include="..\MTApiService\MtMqlRates.cs" Link="MtMqlRates.cs" /> | ||
<Compile Include="..\MTApiService\MtMqlTradeRequest.cs" Link="MtMqlTradeRequest.cs" /> | ||
<Compile Include="..\MTApiService\MtQuote.cs" Link="MtQuote.cs" /> | ||
<Compile Include="..\MTApiService\MtResponse.cs" Link="MtResponse.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="log4net" Version="2.0.12" /> | ||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> | ||
<PackageReference Include="System.ServiceModel.Duplex" Version="4.8.0" /> | ||
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.8.0" /> | ||
</ItemGroup> | ||
<PropertyGroup /> | ||
</Project> |
Oops, something went wrong.