Refactored MTApiService and connectors projects

This commit is contained in:
DW
2017-09-07 17:46:25 +03:00
parent 3a62ff56d7
commit 1f72b2b790
12 changed files with 181 additions and 413 deletions
+10 -26
View File
@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace MTApiService
{
internal class MtExpert: ITaskExecutor
public class MtExpert: ITaskExecutor
{
public delegate void MtQuoteHandler(MtExpert expert, MtQuote quote);
public delegate void MtEventHandler(MtExpert expert, MtEvent e);
@@ -19,12 +19,12 @@ namespace MTApiService
#endregion
#region Public Methods
public MtExpert(int handle, MtQuote quote, IMetaTraderHandler mtHandler)
public MtExpert(int handle, string symbol, double bid, double ask, IMetaTraderHandler mtHandler)
{
if (mtHandler == null)
throw new ArgumentNullException(nameof(mtHandler));
Quote = quote;
_quote = new MtQuote { ExpertHandle = handle, Instrument = symbol, Bid = bid, Ask = ask};
Handle = handle;
_mtHadler = mtHandler;
}
@@ -33,7 +33,6 @@ namespace MTApiService
{
Log.Debug("Deinit: begin.");
IsEnable = false;
FireOnDeinited();
Log.Debug("Deinit: end.");
@@ -120,9 +119,14 @@ namespace MTApiService
Log.Debug("SendEvent: end.");
}
public virtual void SendQuote(MtQuote quote)
{
Quote = quote;
}
public override string ToString()
{
return $"ExpertHandle = {Handle}";
return $"ExpertHandle = {Handle}, Quote = {Quote}";
}
#endregion
@@ -153,7 +157,7 @@ namespace MTApiService
return _quote;
}
}
set
private set
{
lock (_locker)
{
@@ -165,26 +169,6 @@ namespace MTApiService
}
public int Handle { get; }
private bool _isEnable = true;
public bool IsEnable
{
get
{
lock (_locker)
{
return _isEnable;
}
}
private set
{
lock (_locker)
{
_isEnable = value;
}
}
}
#endregion
#region Private Methods