Skip to content

Commit

Permalink
C# 6.0 features.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikasoukhov committed Mar 9, 2016
1 parent 60dc018 commit c0ef8d7
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 77 deletions.
4 changes: 1 addition & 3 deletions Messages/BaseChangeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ namespace StockSharp.Messages
using System.ComponentModel;
using System.Runtime.Serialization;

using Ecng.Common;

using StockSharp.Localization;

/// <summary>
Expand Down Expand Up @@ -65,7 +63,7 @@ protected BaseChangeMessage(MessageTypes type)
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",T(S)={0:yyyy/MM/dd HH:mm:ss.fff}".Put(ServerTime);
return base.ToString() + $",T(S)={ServerTime:yyyy/MM/dd HH:mm:ss.fff}";
}
}
}
4 changes: 1 addition & 3 deletions Messages/BoardMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;

using StockSharp.Localization;

/// <summary>
Expand Down Expand Up @@ -155,7 +153,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",Code={0},Ex={1}".Put(Code, ExchangeCode);
return base.ToString() + $",Code={Code},Ex={ExchangeCode}";
}
}
}
4 changes: 2 additions & 2 deletions Messages/CandleMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ protected CandleMessage CopyTo(CandleMessage copy)
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return "{0},T={1:yyyy/MM/dd HH:mm:ss.fff},O={2},H={3},L={4},C={5},V={6}".Put(Type, OpenTime, OpenPrice, HighPrice, LowPrice, ClosePrice, TotalVolume);
return $"{Type},T={OpenTime:yyyy/MM/dd HH:mm:ss.fff},O={OpenPrice},H={HighPrice},L={LowPrice},C={ClosePrice},V={TotalVolume}";
}
}

Expand Down Expand Up @@ -533,7 +533,7 @@ public Unit BoxSize
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return "Box = {0} RA = {1}".Put(BoxSize, ReversalAmount);
return $"Box = {BoxSize} RA = {ReversalAmount}";
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Messages/Currency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override int GetHashCode()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return "{0} {1}".Put(Value, Type);
return $"{Value} {Type}";
}

/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions Messages/ExecutionMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,7 @@ public ExecutionMessage()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",T(S)={0:yyyy/MM/dd HH:mm:ss.fff},({1}),Sec={2},Ord={3}/{4}/{5},Fail={6},Price={7},OrdVol={8},TrVol={9},Bal={10},TId={11},Pf={12},TPrice={13},UId={14},State={15}"
.Put(ServerTime, ExecutionType, SecurityId, OrderId, TransactionId, OriginalTransactionId,
Error, OrderPrice, OrderVolume, TradeVolume, Balance, TradeId, PortfolioName, TradePrice, UserOrderId, OrderState);
return base.ToString() + $",T(S)={ServerTime:yyyy/MM/dd HH:mm:ss.fff},({ExecutionType}),Sec={SecurityId},Ord={OrderId}/{TransactionId}/{OriginalTransactionId},Fail={Error},Price={OrderPrice},OrdVol={OrderVolume},TrVol={TradeVolume},Bal={Balance},TId={TradeId},Pf={PortfolioName},TPrice={TradePrice},UId={UserOrderId},State={OrderState}";
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Messages/InMemoryMessageChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void Open()

Closed?.Invoke();
}))
.Name("{0} channel thread.".Put(Name))
.Name($"{Name} channel thread.")
//.Culture(CultureInfo.InvariantCulture)
.Launch();
}
Expand Down
2 changes: 1 addition & 1 deletion Messages/Level1ChangeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",Sec={0},Changes={1}".Put(SecurityId, Changes.Select(c => c.ToString()).Join(","));
return base.ToString() + $",Sec={SecurityId},Changes={Changes.Select(c => c.ToString()).Join(",")}";
}
}
}
4 changes: 1 addition & 3 deletions Messages/MarketDataMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ namespace StockSharp.Messages
using System.ComponentModel;
using System.Runtime.Serialization;

using Ecng.Common;

using StockSharp.Localization;

/// <summary>
Expand Down Expand Up @@ -234,7 +232,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",Sec={0},Types={1},IsSubscribe={2},TransId={3},OrigId={4}".Put(SecurityId, DataType, IsSubscribe, TransactionId, OriginalTransactionId);
return base.ToString() + $",Sec={SecurityId},Types={DataType},IsSubscribe={IsSubscribe},TransId={TransactionId},OrigId={OriginalTransactionId}";
}
}
}
2 changes: 1 addition & 1 deletion Messages/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected Message(MessageTypes type)
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return Type + ",T(L)={0:yyyy/MM/dd HH:mm:ss.fff}".Put(LocalTime);
return Type + $",T(L)={LocalTime:yyyy/MM/dd HH:mm:ss.fff}";
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions Messages/NewsMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;
using Ecng.Serialization;

using StockSharp.Localization;
Expand Down Expand Up @@ -118,7 +117,7 @@ public NewsMessage()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",Sec={0},Head={1}".Put(SecurityId, Headline);
return base.ToString() + $",Sec={SecurityId},Head={Headline}";
}

/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions Messages/OrderCancelMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;

/// <summary>
/// A message containing the data for the cancellation of the order.
/// </summary>
Expand Down Expand Up @@ -104,7 +102,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",OriginTransId={0},TransId={1},OrderId={2}".Put(OrderTransactionId, TransactionId, OrderId);
return base.ToString() + $",OriginTransId={OrderTransactionId},TransId={TransactionId},OrderId={OrderId}";
}
}
}
13 changes: 1 addition & 12 deletions Messages/OrderGroupCancelMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;

using StockSharp.Localization;

/// <summary>
Expand All @@ -29,15 +27,6 @@ namespace StockSharp.Messages
[Serializable]
public class OrderGroupCancelMessage : OrderMessage
{
///// <summary>
///// Тип инструмента. Если значение <see langword="null"/>, то отмена идет по всем типам инструментов.
///// </summary>
//[DataMember]
//[DisplayName("Тип")]
//[Description("Тип инструмента.")]
//[MainCategory]
//public SecurityTypes? SecurityType { get; set; }

/// <summary>
/// <see langword="true" />, if cancel only a stop orders, <see langword="false" /> - if regular orders, <see langword="null" /> - both.
/// </summary>
Expand Down Expand Up @@ -70,7 +59,7 @@ public OrderGroupCancelMessage()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",IsStop={0},Side={1},SecType={2}".Put(IsStop, Side, SecurityType);
return base.ToString() + $",IsStop={IsStop},Side={Side},SecType={SecurityType}";
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Messages/OrderPairReplaceMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",{0},{1}".Put(Message1, Message2);
return base.ToString() + $",{Message1},{Message2}";
}
}
}
2 changes: 1 addition & 1 deletion Messages/OrderRegisterMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",TransId={0},Price={1},Side={2},OrdType={3},Vol={4},Sec={5}".Put(TransactionId, Price, Side, OrderType, Volume, SecurityId);
return base.ToString() + $",TransId={TransactionId},Price={Price},Side={Side},OrdType={OrderType},Vol={Volume},Sec={SecurityId}";
}
}
}
4 changes: 1 addition & 3 deletions Messages/OrderReplaceMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;

/// <summary>
/// The message containing the information for modify order.
/// </summary>
Expand Down Expand Up @@ -94,7 +92,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",OldTransId={0},OldOrdId={1},NewTransId={2}".Put(OldTransactionId, OldOrderId, TransactionId);
return base.ToString() + $",OldTransId={OldTransactionId},OldOrdId={OldOrderId},NewTransId={TransactionId}";
}
}
}
4 changes: 1 addition & 3 deletions Messages/OrderStatusMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;

/// <summary>
/// A message requesting current registered orders and trades.
/// </summary>
Expand Down Expand Up @@ -65,7 +63,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",TransId={0}".Put(TransactionId);
return base.ToString() + $",TransId={TransactionId}";
}
}
}
2 changes: 1 addition & 1 deletion Messages/PortfolioChangeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",P={0},Changes={1}".Put(PortfolioName, Changes.Select(c => c.ToString()).Join(","));
return base.ToString() + $",P={PortfolioName},Changes={Changes.Select(c => c.ToString()).Join(",")}";
}
}
}
4 changes: 1 addition & 3 deletions Messages/PortfolioLookupMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;

/// <summary>
/// Message security lookup for specified criteria.
/// </summary>
Expand Down Expand Up @@ -50,7 +48,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",TransId={0},Curr={1},Board={2},IsSubscribe={3}".Put(TransactionId, Currency, BoardCode, IsSubscribe);
return base.ToString() + $",TransId={TransactionId},Curr={Currency},Board={BoardCode},IsSubscribe={IsSubscribe}";
}
}
}
4 changes: 1 addition & 3 deletions Messages/PortfolioLookupResultMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;

/// <summary>
/// Portfolio lookup result message.
/// </summary>
Expand Down Expand Up @@ -67,7 +65,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",Orig={0}".Put(OriginalTransactionId);
return base.ToString() + $",Orig={OriginalTransactionId}";
}
}
}
4 changes: 1 addition & 3 deletions Messages/PortfolioMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;

using StockSharp.Localization;

/// <summary>
Expand Down Expand Up @@ -131,7 +129,7 @@ protected PortfolioMessage(MessageTypes type)
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",Name={0}".Put(PortfolioName);
return base.ToString() + $",Name={PortfolioName}";
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Messages/PositionChangeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",Sec={0},P={1},Changes={2}".Put(SecurityId, PortfolioName, Changes.Select(c => c.ToString()).Join(","));
return base.ToString() + $",Sec={SecurityId},P={PortfolioName},Changes={Changes.Select(c => c.ToString()).Join(",")}";
}
}
}
3 changes: 1 addition & 2 deletions Messages/PositionMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace StockSharp.Messages
using System;
using System.Runtime.Serialization;

using Ecng.Common;
using Ecng.Serialization;

using StockSharp.Localization;
Expand Down Expand Up @@ -94,7 +93,7 @@ public PositionMessage()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",Sec={0},P={1}".Put(SecurityId, PortfolioName);
return base.ToString() + $",Sec={SecurityId},P={PortfolioName}";
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion Messages/QuoteChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public override int GetHashCode()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return "{0} {1} {2}".Put(Side == Sides.Buy ? LocalizedStrings.Bid : LocalizedStrings.Ask, Price, Volume);
var side = Side == Sides.Buy ? LocalizedStrings.Bid : LocalizedStrings.Ask;
return $"{side} {Price} {Volume}";
}
}
}
3 changes: 1 addition & 2 deletions Messages/QuoteChangeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace StockSharp.Messages
using System.Linq;
using System.Runtime.Serialization;

using Ecng.Common;
using Ecng.Serialization;

using StockSharp.Localization;
Expand Down Expand Up @@ -147,7 +146,7 @@ public override Message Clone()
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return base.ToString() + ",T(S)={0:yyyy/MM/dd HH:mm:ss.fff}".Put(ServerTime);
return base.ToString() + $",T(S)={ServerTime:yyyy/MM/dd HH:mm:ss.fff}";
}
}
}
6 changes: 2 additions & 4 deletions Messages/SecurityId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ private int EnsureGetHashCode()
{
if (_hashCode == 0)
{
_hashCode = _native != null
? _native.GetHashCode()
: (_securityCode + _boardCode).ToLowerInvariant().GetHashCode();
_hashCode = _native?.GetHashCode() ?? (_securityCode + _boardCode).ToLowerInvariant().GetHashCode();
}

return _hashCode;
Expand Down Expand Up @@ -225,7 +223,7 @@ public bool Equals(SecurityId other)
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return "S#:{0}@{1}, Native:{2},Type:{3}".Put(SecurityCode, BoardCode, Native, SecurityType);
return $"S#:{SecurityCode}@{BoardCode}, Native:{Native},Type:{SecurityType}";
}
}
}
Loading

0 comments on commit c0ef8d7

Please sign in to comment.