diff --git a/Algo/BasketMessageAdapter.cs b/Algo/BasketMessageAdapter.cs index 0d55e4208a..f8d79095ac 100644 --- a/Algo/BasketMessageAdapter.cs +++ b/Algo/BasketMessageAdapter.cs @@ -670,10 +670,7 @@ private void ProcessPortfolioMessage(string portfolioName, Message message) { var a = _hearbeatAdapters.TryGetValue(adapter); - if (a == null) - throw new InvalidOperationException(LocalizedStrings.Str1838Params.Put(adapter.GetType())); - - adapter = a; + adapter = a ?? throw new InvalidOperationException(LocalizedStrings.Str1838Params.Put(adapter.GetType())); } adapter.SendInMessage(message); diff --git a/Algo/BasketPortfolio.cs b/Algo/BasketPortfolio.cs index 73653811bd..fdd8c5794f 100644 --- a/Algo/BasketPortfolio.cs +++ b/Algo/BasketPortfolio.cs @@ -55,10 +55,7 @@ private sealed class WeightedPosition : BasketPosition { public WeightedPosition(WeightedPortfolio portfolio, IEnumerable innerPositions) { - if (innerPositions == null) - throw new ArgumentNullException(nameof(innerPositions)); - - _innerPositions = innerPositions; + _innerPositions = innerPositions ?? throw new ArgumentNullException(nameof(innerPositions)); decimal? beginValue = null; decimal? currentValue = null; @@ -99,10 +96,7 @@ public WeightedPosition(WeightedPortfolio portfolio, IEnumerable inner public WeightsDictionary(WeightedPortfolio parent, IConnector connector) { - if (parent == null) - throw new ArgumentNullException(nameof(parent)); - - _parent = parent; + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); _connector = connector; } diff --git a/Algo/Candles/CandleManager.cs b/Algo/Candles/CandleManager.cs index 716304a0ba..671187fc82 100644 --- a/Algo/Candles/CandleManager.cs +++ b/Algo/Candles/CandleManager.cs @@ -45,10 +45,7 @@ private sealed class SourceInfo : Disposable public SourceInfo(ICandleSource source, CandleManager manager) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - _source = source; + _source = source ?? throw new ArgumentNullException(nameof(source)); _manager = manager; _source.Processing += OnProcessing; @@ -81,10 +78,7 @@ protected override void DisposeManaged() public CandleManagerSourceList(CandleManager manager) { - if (manager == null) - throw new ArgumentNullException(nameof(manager)); - - _manager = manager; + _manager = manager ?? throw new ArgumentNullException(nameof(manager)); } protected override void OnAdded(ICandleSource item) @@ -136,10 +130,7 @@ private sealed class ExternalCandleSource : Disposable, ICandleSource public ExternalCandleSource(IExternalCandleSource source) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - _source = source; + _source = source ?? throw new ArgumentNullException(nameof(source)); _source.NewCandles += OnNewCandles; _source.Stopped += OnStopped; } @@ -222,10 +213,7 @@ private sealed class ConnectorCandleSource : Disposable, ICandleSource public ConnectorCandleSource(Connector connector) { - if (connector == null) - throw new ArgumentNullException(nameof(connector)); - - _connector = connector; + _connector = connector ?? throw new ArgumentNullException(nameof(connector)); _connector.CandleSeriesProcessing += OnConnectorProcessingCandle; _connector.CandleSeriesStopped += OnConnectorCandleSeriesStopped; } diff --git a/Algo/Candles/CandleManagerContainer.cs b/Algo/Candles/CandleManagerContainer.cs index f0e1238541..96eeb39ae7 100644 --- a/Algo/Candles/CandleManagerContainer.cs +++ b/Algo/Candles/CandleManagerContainer.cs @@ -53,10 +53,7 @@ private sealed class SeriesInfo public SeriesInfo(CandleManagerContainer container) { - if (container == null) - throw new ArgumentNullException(nameof(container)); - - _container = container; + _container = container ?? throw new ArgumentNullException(nameof(container)); } public int CandleCount => _allCandles.Count; diff --git a/Algo/Candles/CandlesHolder.cs b/Algo/Candles/CandlesHolder.cs index ee0c180c16..fc6f4dd6be 100644 --- a/Algo/Candles/CandlesHolder.cs +++ b/Algo/Candles/CandlesHolder.cs @@ -26,10 +26,7 @@ private class CandlesSeriesHolder /// Candles series. public CandlesSeriesHolder(CandleSeries series) { - if (series == null) - throw new ArgumentNullException(nameof(series)); - - Series = series; + Series = series ?? throw new ArgumentNullException(nameof(series)); } /// diff --git a/Algo/Candles/IndexCandleBuilder.cs b/Algo/Candles/IndexCandleBuilder.cs index cd8e3e4f7a..3b02fa5ff6 100644 --- a/Algo/Candles/IndexCandleBuilder.cs +++ b/Algo/Candles/IndexCandleBuilder.cs @@ -146,14 +146,8 @@ private Candle CreateFilledCandle(Candle candle) public IndexCandleBuilder(IndexSecurity security, Type candleType) { - if (security == null) - throw new ArgumentNullException(nameof(security)); - - if (candleType == null) - throw new ArgumentNullException(nameof(candleType)); - - _security = security; - _candleType = candleType; + _security = security ?? throw new ArgumentNullException(nameof(security)); + _candleType = candleType ?? throw new ArgumentNullException(nameof(candleType)); FillSecurityIndecies(_security); _bufferSize = _securityIndecies.Values.Distinct().Count(); } diff --git a/Algo/Candles/IndexSecurityCandleManagerSource.cs b/Algo/Candles/IndexSecurityCandleManagerSource.cs index 4850766493..45e4ea0b72 100644 --- a/Algo/Candles/IndexSecurityCandleManagerSource.cs +++ b/Algo/Candles/IndexSecurityCandleManagerSource.cs @@ -44,27 +44,18 @@ private sealed class IndexSeriesInfo : Disposable public IndexSeriesInfo(ICandleManager candleManager, Type candleType, IEnumerable innerSeries, DateTimeOffset? from, DateTimeOffset? to, IndexSecurity security, Action processing, Action stopped) { - if (candleManager == null) - throw new ArgumentNullException(nameof(candleManager)); - if (innerSeries == null) throw new ArgumentNullException(nameof(innerSeries)); if (security == null) throw new ArgumentNullException(nameof(security)); - if (processing == null) - throw new ArgumentNullException(nameof(processing)); - - if (stopped == null) - throw new ArgumentNullException(nameof(stopped)); - - _candleManager = candleManager; + _candleManager = candleManager ?? throw new ArgumentNullException(nameof(candleManager)); _innerSeries = innerSeries.ToHashSet(); _from = from; _to = to; - _processing = processing; - _stopped = stopped; + _processing = processing ?? throw new ArgumentNullException(nameof(processing)); + _stopped = stopped ?? throw new ArgumentNullException(nameof(stopped)); candleManager.Processing += OnInnerSourceProcessCandle; candleManager.Stopped += OnInnerSourceStopped; @@ -153,16 +144,10 @@ protected override void DisposeManaged() public IndexSecurityCandleManagerSource(ICandleManager candleManager, ISecurityProvider securityProvider, DateTimeOffset? from, DateTimeOffset? to) { - if (candleManager == null) - throw new ArgumentNullException(nameof(candleManager)); - - if (securityProvider == null) - throw new ArgumentNullException(nameof(securityProvider)); - - _securityProvider = securityProvider; + _securityProvider = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider)); _from = from; _to = to; - _candleManager = candleManager; + _candleManager = candleManager ?? throw new ArgumentNullException(nameof(candleManager)); } public int SpeedPriority => 2; diff --git a/Algo/Commissions/CommissionMessageAdapter.cs b/Algo/Commissions/CommissionMessageAdapter.cs index 158706b7dd..6adeb702b7 100644 --- a/Algo/Commissions/CommissionMessageAdapter.cs +++ b/Algo/Commissions/CommissionMessageAdapter.cs @@ -41,13 +41,7 @@ public CommissionMessageAdapter(IMessageAdapter innerAdapter) public ICommissionManager CommissionManager { get => _commissionManager; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _commissionManager = value; - } + set => _commissionManager = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/Connector_Subscription.cs b/Algo/Connector_Subscription.cs index dbc49f2d98..4a5c29521f 100644 --- a/Algo/Connector_Subscription.cs +++ b/Algo/Connector_Subscription.cs @@ -40,10 +40,7 @@ private sealed class SubscriptionManager public SubscriptionManager(Connector connector) { - if (connector == null) - throw new ArgumentNullException(nameof(connector)); - - _connector = connector; + _connector = connector ?? throw new ArgumentNullException(nameof(connector)); } public void ClearCache() diff --git a/Algo/Derivatives/BasketBlackScholes.cs b/Algo/Derivatives/BasketBlackScholes.cs index 1b29e33912..ca82929d97 100644 --- a/Algo/Derivatives/BasketBlackScholes.cs +++ b/Algo/Derivatives/BasketBlackScholes.cs @@ -48,10 +48,7 @@ private sealed class InnerModelList : CachedSynchronizedList, IInn public InnerModelList(BasketBlackScholes parent) { - if (parent == null) - throw new ArgumentNullException(nameof(parent)); - - _parent = parent; + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); } BlackScholes IInnerModelList.this[Security option] @@ -87,11 +84,8 @@ protected override bool OnInserting(int index, BlackScholes item) public BasketBlackScholes(ISecurityProvider securityProvider, IMarketDataProvider dataProvider, IPositionProvider positionProvider) : base(securityProvider, dataProvider) { - if (positionProvider == null) - throw new ArgumentNullException(nameof(positionProvider)); - _innerModels = new InnerModelList(this); - PositionProvider = positionProvider; + PositionProvider = positionProvider ?? throw new ArgumentNullException(nameof(positionProvider)); } /// @@ -103,12 +97,9 @@ public BasketBlackScholes(ISecurityProvider securityProvider, IMarketDataProvide public BasketBlackScholes(Security underlyingAsset, IMarketDataProvider dataProvider, IPositionProvider positionProvider) : base(underlyingAsset, dataProvider) { - if (positionProvider == null) - throw new ArgumentNullException(nameof(positionProvider)); - _innerModels = new InnerModelList(this); UnderlyingAsset = underlyingAsset; - PositionProvider = positionProvider; + PositionProvider = positionProvider ?? throw new ArgumentNullException(nameof(positionProvider)); } /// diff --git a/Algo/Derivatives/BasketStrike.cs b/Algo/Derivatives/BasketStrike.cs index 2f9ba11567..e0368d4404 100644 --- a/Algo/Derivatives/BasketStrike.cs +++ b/Algo/Derivatives/BasketStrike.cs @@ -37,18 +37,9 @@ public abstract class BasketStrike : BasketSecurity /// The market data provider. protected BasketStrike(Security underlyingAsset, ISecurityProvider securityProvider, IMarketDataProvider dataProvider) { - if (underlyingAsset == null) - throw new ArgumentNullException(nameof(underlyingAsset)); - - if (securityProvider == null) - throw new ArgumentNullException(nameof(securityProvider)); - - if (dataProvider == null) - throw new ArgumentNullException(nameof(dataProvider)); - - UnderlyingAsset = underlyingAsset; - SecurityProvider = securityProvider; - DataProvider = dataProvider; + UnderlyingAsset = underlyingAsset ?? throw new ArgumentNullException(nameof(underlyingAsset)); + SecurityProvider = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider)); + DataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider)); } /// @@ -110,10 +101,7 @@ public class OffsetBasketStrike : BasketStrike public OffsetBasketStrike(Security underlyingSecurity, ISecurityProvider securityProvider, IMarketDataProvider dataProvider, Range strikeOffset) : base(underlyingSecurity, securityProvider, dataProvider) { - if (strikeOffset == null) - throw new ArgumentNullException(nameof(strikeOffset)); - - _strikeOffset = strikeOffset; + _strikeOffset = strikeOffset ?? throw new ArgumentNullException(nameof(strikeOffset)); } /// @@ -180,10 +168,7 @@ public class VolatilityBasketStrike : BasketStrike public VolatilityBasketStrike(Security underlyingAsset, ISecurityProvider securityProvider, IMarketDataProvider dataProvider, Range volatilityRange) : base(underlyingAsset, securityProvider, dataProvider) { - if (volatilityRange == null) - throw new ArgumentNullException(nameof(volatilityRange)); - - _volatilityRange = volatilityRange; + _volatilityRange = volatilityRange ?? throw new ArgumentNullException(nameof(volatilityRange)); } /// diff --git a/Algo/Derivatives/BlackScholes.cs b/Algo/Derivatives/BlackScholes.cs index ff4cb975e7..0d375e4a71 100644 --- a/Algo/Derivatives/BlackScholes.cs +++ b/Algo/Derivatives/BlackScholes.cs @@ -35,14 +35,8 @@ public class BlackScholes : IBlackScholes /// The market data provider. protected BlackScholes(ISecurityProvider securityProvider, IMarketDataProvider dataProvider) { - if (securityProvider == null) - throw new ArgumentNullException(nameof(securityProvider)); - - if (dataProvider == null) - throw new ArgumentNullException(nameof(dataProvider)); - - SecurityProvider = securityProvider; - DataProvider = dataProvider; + SecurityProvider = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider)); + DataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider)); } /// @@ -54,10 +48,7 @@ protected BlackScholes(ISecurityProvider securityProvider, IMarketDataProvider d public BlackScholes(Security option, ISecurityProvider securityProvider, IMarketDataProvider dataProvider) : this(securityProvider, dataProvider) { - if (option == null) - throw new ArgumentNullException(nameof(option)); - - Option = option; + Option = option ?? throw new ArgumentNullException(nameof(option)); } /// @@ -67,14 +58,8 @@ public BlackScholes(Security option, ISecurityProvider securityProvider, IMarket /// The market data provider. protected BlackScholes(Security underlyingAsset, IMarketDataProvider dataProvider) { - if (underlyingAsset == null) - throw new ArgumentNullException(nameof(underlyingAsset)); - - if (dataProvider == null) - throw new ArgumentNullException(nameof(dataProvider)); - - _underlyingAsset = underlyingAsset; - DataProvider = dataProvider; + _underlyingAsset = underlyingAsset ?? throw new ArgumentNullException(nameof(underlyingAsset)); + DataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider)); } /// @@ -86,10 +71,7 @@ protected BlackScholes(Security underlyingAsset, IMarketDataProvider dataProvide public BlackScholes(Security option, Security underlyingAsset, IMarketDataProvider dataProvider) : this(underlyingAsset, dataProvider) { - if (option == null) - throw new ArgumentNullException(nameof(option)); - - Option = option; + Option = option ?? throw new ArgumentNullException(nameof(option)); } /// diff --git a/Algo/Derivatives/Synthetic.cs b/Algo/Derivatives/Synthetic.cs index 9ef6f5dbcb..b7f313ee32 100644 --- a/Algo/Derivatives/Synthetic.cs +++ b/Algo/Derivatives/Synthetic.cs @@ -37,14 +37,8 @@ public class Synthetic /// The provider of information about instruments. public Synthetic(Security security, ISecurityProvider provider) { - if (security == null) - throw new ArgumentNullException(nameof(security)); - - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - _security = security; - _provider = provider; + _security = security ?? throw new ArgumentNullException(nameof(security)); + _provider = provider ?? throw new ArgumentNullException(nameof(provider)); } private Security Option diff --git a/Algo/EntityCache.cs b/Algo/EntityCache.cs index ac7b561118..0b852ef755 100644 --- a/Algo/EntityCache.cs +++ b/Algo/EntityCache.cs @@ -61,10 +61,7 @@ private sealed class OrderInfo public OrderInfo(Order order, bool raiseNewOrder = true) { - if (order == null) - throw new ArgumentNullException(nameof(order)); - - Order = order; + Order = order ?? throw new ArgumentNullException(nameof(order)); _raiseNewOrder = raiseNewOrder; } @@ -265,13 +262,7 @@ private void AddOrder(Order order) public IEntityFactory EntityFactory { get => _entityFactory; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _entityFactory = value; - } + set => _entityFactory = value ?? throw new ArgumentNullException(nameof(value)); } private IExchangeInfoProvider _exchangeInfoProvider = new InMemoryExchangeInfoProvider(); @@ -279,13 +270,7 @@ public IEntityFactory EntityFactory public IExchangeInfoProvider ExchangeInfoProvider { get => _exchangeInfoProvider; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _exchangeInfoProvider = value; - } + set => _exchangeInfoProvider = value ?? throw new ArgumentNullException(nameof(value)); } private readonly CachedSynchronizedList _orders = new CachedSynchronizedList(); diff --git a/Algo/Export/BaseExporter.cs b/Algo/Export/BaseExporter.cs index b73a0e6b1c..3c87aefc86 100644 --- a/Algo/Export/BaseExporter.cs +++ b/Algo/Export/BaseExporter.cs @@ -47,15 +47,12 @@ protected BaseExporter(Security security, object arg, Func isCancelle //if (security == null) // throw new ArgumentNullException(nameof(security)); - if (isCancelled == null) - throw new ArgumentNullException(nameof(isCancelled)); - if (path.IsEmpty()) throw new ArgumentNullException(nameof(path)); Security = security; Arg = arg; - _isCancelled = isCancelled; + _isCancelled = isCancelled ?? throw new ArgumentNullException(nameof(isCancelled)); Path = path; } diff --git a/Algo/Export/ExcelExporter.cs b/Algo/Export/ExcelExporter.cs index e210a4adc6..d2243d04a5 100644 --- a/Algo/Export/ExcelExporter.cs +++ b/Algo/Export/ExcelExporter.cs @@ -47,10 +47,7 @@ public class ExcelExporter : BaseExporter public ExcelExporter(Security security, object arg, Func isCancelled, string fileName, Action breaked) : base(security, arg, isCancelled, fileName) { - if (breaked == null) - throw new ArgumentNullException(nameof(breaked)); - - _breaked = breaked; + _breaked = breaked ?? throw new ArgumentNullException(nameof(breaked)); } /// diff --git a/Algo/Export/IndicatorValue.cs b/Algo/Export/IndicatorValue.cs index f85ca3cab6..9a127b69ac 100644 --- a/Algo/Export/IndicatorValue.cs +++ b/Algo/Export/IndicatorValue.cs @@ -52,13 +52,11 @@ private static void FillValues(IIndicatorValue value, ICollection valu { values.Add(value.IsEmpty ? (decimal?)null : value.GetValue()); } - else if (value is ComplexIndicatorValue) + else if (value is ComplexIndicatorValue complexValue) { - var complexInd = (ComplexIndicatorValue)value; - foreach (var innerIndicator in ((IComplexIndicator)value.Indicator).InnerIndicators) { - var innerValue = complexInd.InnerValues.TryGetValue(innerIndicator); + var innerValue = complexValue.InnerValues.TryGetValue(innerIndicator); if (innerValue == null) values.Add(null); diff --git a/Algo/Export/StockSharpExporter.cs b/Algo/Export/StockSharpExporter.cs index aed4bd7a01..7e6bbf7757 100644 --- a/Algo/Export/StockSharpExporter.cs +++ b/Algo/Export/StockSharpExporter.cs @@ -46,14 +46,8 @@ public class StockSharpExporter : BaseExporter public StockSharpExporter(Security security, object arg, Func isCancelled, IStorageRegistry storageRegistry, IMarketDataDrive drive, StorageFormats format) : base(security, arg, isCancelled, drive.Path) { - if (storageRegistry == null) - throw new ArgumentNullException(nameof(storageRegistry)); - - if (drive == null) - throw new ArgumentNullException(nameof(drive)); - - _storageRegistry = storageRegistry; - _drive = drive; + _storageRegistry = storageRegistry ?? throw new ArgumentNullException(nameof(storageRegistry)); + _drive = drive ?? throw new ArgumentNullException(nameof(drive)); _format = format; } diff --git a/Algo/FilterableSecurityProvider.cs b/Algo/FilterableSecurityProvider.cs index 5fb21d7e48..91cc115a9f 100644 --- a/Algo/FilterableSecurityProvider.cs +++ b/Algo/FilterableSecurityProvider.cs @@ -43,10 +43,7 @@ public class FilterableSecurityProvider : Disposable, ISecurityProvider ///// Filter for instruments exclusion. public FilterableSecurityProvider(ISecurityProvider provider, bool ownProvider = false/*, Func excludeFilter = null*/) { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - _provider = provider; + _provider = provider ?? throw new ArgumentNullException(nameof(provider)); _ownProvider = ownProvider; //ExcludeFilter = excludeFilter; diff --git a/Algo/IMarketRule.cs b/Algo/IMarketRule.cs index 686a43ba80..67be214c30 100644 --- a/Algo/IMarketRule.cs +++ b/Algo/IMarketRule.cs @@ -215,13 +215,10 @@ public virtual IMarketRuleContainer Container get => _container; set { - if (value == null) - throw new ArgumentNullException(nameof(value)); - if (Container != null) throw new ArgumentException(LocalizedStrings.Str1091Params.Put(Name, Container)); - _container = value; + _container = value ?? throw new ArgumentNullException(nameof(value)); //_container.AddRuleLog(LogLevels.Info, this, "Добавлено."); } @@ -234,10 +231,7 @@ public virtual IMarketRuleContainer Container /// Rule. public MarketRule Until(Func canFinish) { - if (canFinish == null) - throw new ArgumentNullException(nameof(canFinish)); - - _canFinish = canFinish; + _canFinish = canFinish ?? throw new ArgumentNullException(nameof(canFinish)); return this; } @@ -248,13 +242,10 @@ public MarketRule Until(Func canFinish) /// Rule. public MarketRule Do(Action action) { - if (action == null) - throw new ArgumentNullException(nameof(action)); - //return Do((r, a) => action(a)); _process = ProcessRuleVoid; - _actionVoid = action; + _actionVoid = action ?? throw new ArgumentNullException(nameof(action)); return this; } diff --git a/Algo/IMarketRuleList.cs b/Algo/IMarketRuleList.cs index fef05a3714..d0aa157b23 100644 --- a/Algo/IMarketRuleList.cs +++ b/Algo/IMarketRuleList.cs @@ -64,10 +64,7 @@ public class MarketRuleList : SynchronizedSet, IMarketRuleList /// The rules container. public MarketRuleList(IMarketRuleContainer container) { - if (container == null) - throw new ArgumentNullException(nameof(container)); - - _container = container; + _container = container ?? throw new ArgumentNullException(nameof(container)); } /// diff --git a/Algo/Import/FieldMapping.cs b/Algo/Import/FieldMapping.cs index 7fedaaaf5f..76505d5019 100644 --- a/Algo/Import/FieldMapping.cs +++ b/Algo/Import/FieldMapping.cs @@ -327,10 +327,7 @@ public class FieldMapping : FieldMapping public FieldMapping(string name, string displayName, string description, Action apply, bool isExtended = false) : base(name, displayName, description, typeof(TValue), isExtended) { - if (apply == null) - throw new ArgumentNullException(nameof(apply)); - - _apply = apply; + _apply = apply ?? throw new ArgumentNullException(nameof(apply)); } /// diff --git a/Algo/Indicators/Acceleration.cs b/Algo/Indicators/Acceleration.cs index 51b0a85e06..22e24b3503 100644 --- a/Algo/Indicators/Acceleration.cs +++ b/Algo/Indicators/Acceleration.cs @@ -47,14 +47,8 @@ public Acceleration() /// The moving average. public Acceleration(AwesomeOscillator ao, SimpleMovingAverage sma) { - if (ao == null) - throw new ArgumentNullException(nameof(ao)); - - if (sma == null) - throw new ArgumentNullException(nameof(sma)); - - Ao = ao; - Sma = sma; + Ao = ao ?? throw new ArgumentNullException(nameof(ao)); + Sma = sma ?? throw new ArgumentNullException(nameof(sma)); } /// diff --git a/Algo/Indicators/AverageTrueRange.cs b/Algo/Indicators/AverageTrueRange.cs index 152b2d3070..e44d1f6a9a 100644 --- a/Algo/Indicators/AverageTrueRange.cs +++ b/Algo/Indicators/AverageTrueRange.cs @@ -44,14 +44,8 @@ public AverageTrueRange() /// True range. public AverageTrueRange(LengthIndicator movingAverage, TrueRange trueRange) { - if (movingAverage == null) - throw new ArgumentNullException(nameof(movingAverage)); - - if (trueRange == null) - throw new ArgumentNullException(nameof(trueRange)); - - MovingAverage = movingAverage; - TrueRange = trueRange; + MovingAverage = movingAverage ?? throw new ArgumentNullException(nameof(movingAverage)); + TrueRange = trueRange ?? throw new ArgumentNullException(nameof(trueRange)); } /// diff --git a/Algo/Indicators/AwesomeOscillator.cs b/Algo/Indicators/AwesomeOscillator.cs index c06a295b99..7f4c3ddec0 100644 --- a/Algo/Indicators/AwesomeOscillator.cs +++ b/Algo/Indicators/AwesomeOscillator.cs @@ -47,14 +47,8 @@ public AwesomeOscillator() /// Short moving average. public AwesomeOscillator(SimpleMovingAverage longSma, SimpleMovingAverage shortSma) { - if (longSma == null) - throw new ArgumentNullException(nameof(longSma)); - - if (shortSma == null) - throw new ArgumentNullException(nameof(shortSma)); - - ShortMa = shortSma; - LongMa = longSma; + ShortMa = shortSma ?? throw new ArgumentNullException(nameof(shortSma)); + LongMa = longSma ?? throw new ArgumentNullException(nameof(longSma)); MedianPrice = new MedianPrice(); } diff --git a/Algo/Indicators/BollingerBand.cs b/Algo/Indicators/BollingerBand.cs index d7e7ca6924..718ceb8a9c 100644 --- a/Algo/Indicators/BollingerBand.cs +++ b/Algo/Indicators/BollingerBand.cs @@ -34,14 +34,8 @@ public class BollingerBand : BaseIndicator /// Standard deviation. public BollingerBand(LengthIndicator ma, StandardDeviation dev) { - if (ma == null) - throw new ArgumentNullException(nameof(ma)); - - if (dev == null) - throw new ArgumentNullException(nameof(dev)); - - _ma = ma; - _dev = dev; + _ma = ma ?? throw new ArgumentNullException(nameof(ma)); + _dev = dev ?? throw new ArgumentNullException(nameof(dev)); } /// diff --git a/Algo/Indicators/GatorOscillator.cs b/Algo/Indicators/GatorOscillator.cs index c50b04b706..75f7050ff2 100644 --- a/Algo/Indicators/GatorOscillator.cs +++ b/Algo/Indicators/GatorOscillator.cs @@ -53,10 +53,7 @@ public GatorOscillator() public GatorOscillator(Alligator alligator, GatorHistogram histogram1, GatorHistogram histogram2) : base(histogram1, histogram2) { - if (alligator == null) - throw new ArgumentNullException(nameof(alligator)); - - _alligator = alligator; + _alligator = alligator ?? throw new ArgumentNullException(nameof(alligator)); Histogram1 = histogram1; Histogram2 = histogram2; } diff --git a/Algo/Indicators/IIndicatorValue.cs b/Algo/Indicators/IIndicatorValue.cs index 0ac6262082..cf96b488ce 100644 --- a/Algo/Indicators/IIndicatorValue.cs +++ b/Algo/Indicators/IIndicatorValue.cs @@ -91,10 +91,7 @@ public abstract class BaseIndicatorValue : IIndicatorValue /// Indicator. protected BaseIndicatorValue(IIndicator indicator) { - if (indicator == null) - throw new ArgumentNullException(nameof(indicator)); - - Indicator = indicator; + Indicator = indicator ?? throw new ArgumentNullException(nameof(indicator)); IsFormed = indicator.IsFormed; } @@ -344,10 +341,7 @@ public CandleIndicatorValue(IIndicator indicator, Candle value, Func diff --git a/Algo/Indicators/IchimokuSenkouALine.cs b/Algo/Indicators/IchimokuSenkouALine.cs index bda66bb72a..fd2ea5fa02 100644 --- a/Algo/Indicators/IchimokuSenkouALine.cs +++ b/Algo/Indicators/IchimokuSenkouALine.cs @@ -30,14 +30,8 @@ public class IchimokuSenkouALine : LengthIndicator /// Kijun line. public IchimokuSenkouALine(IchimokuLine tenkan, IchimokuLine kijun) { - if (tenkan == null) - throw new ArgumentNullException(nameof(tenkan)); - - if (kijun == null) - throw new ArgumentNullException(nameof(kijun)); - - Tenkan = tenkan; - Kijun = kijun; + Tenkan = tenkan ?? throw new ArgumentNullException(nameof(tenkan)); + Kijun = kijun ?? throw new ArgumentNullException(nameof(kijun)); } /// diff --git a/Algo/Indicators/IchimokuSenkouBLine.cs b/Algo/Indicators/IchimokuSenkouBLine.cs index d73179c9dd..1ebbabf7b3 100644 --- a/Algo/Indicators/IchimokuSenkouBLine.cs +++ b/Algo/Indicators/IchimokuSenkouBLine.cs @@ -38,10 +38,7 @@ public class IchimokuSenkouBLine : LengthIndicator /// Kijun line. public IchimokuSenkouBLine(IchimokuLine kijun) { - if (kijun == null) - throw new ArgumentNullException(nameof(kijun)); - - Kijun = kijun; + Kijun = kijun ?? throw new ArgumentNullException(nameof(kijun)); } /// diff --git a/Algo/Indicators/MovingAverageConvergenceDivergence.cs b/Algo/Indicators/MovingAverageConvergenceDivergence.cs index a8e70a1a6f..fedd795b3b 100644 --- a/Algo/Indicators/MovingAverageConvergenceDivergence.cs +++ b/Algo/Indicators/MovingAverageConvergenceDivergence.cs @@ -44,14 +44,8 @@ public MovingAverageConvergenceDivergence() /// Short moving average. public MovingAverageConvergenceDivergence(ExponentialMovingAverage longMa, ExponentialMovingAverage shortMa) { - if (longMa == null) - throw new ArgumentNullException(nameof(longMa)); - - if (shortMa == null) - throw new ArgumentNullException(nameof(shortMa)); - - ShortMa = shortMa; - LongMa = longMa; + ShortMa = shortMa ?? throw new ArgumentNullException(nameof(shortMa)); + LongMa = longMa ?? throw new ArgumentNullException(nameof(longMa)); } /// diff --git a/Algo/Latency/LatencyMessageAdapter.cs b/Algo/Latency/LatencyMessageAdapter.cs index e1c78bb169..88d566e9fc 100644 --- a/Algo/Latency/LatencyMessageAdapter.cs +++ b/Algo/Latency/LatencyMessageAdapter.cs @@ -41,13 +41,7 @@ public LatencyMessageAdapter(IMessageAdapter innerAdapter) public ILatencyManager LatencyManager { get => _latencyManager; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _latencyManager = value; - } + set => _latencyManager = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/MarketRuleHelper.cs b/Algo/MarketRuleHelper.cs index 44faa55097..bf542da313 100644 --- a/Algo/MarketRuleHelper.cs +++ b/Algo/MarketRuleHelper.cs @@ -41,14 +41,8 @@ private abstract class OrderRule : MarketRule protected OrderRule(Order order, IConnector connector) : base(order) { - if (order == null) - throw new ArgumentNullException(nameof(order)); - - if (connector == null) - throw new ArgumentNullException(nameof(connector)); - - Order = order; - Connector = connector; + Order = order ?? throw new ArgumentNullException(nameof(order)); + Connector = connector ?? throw new ArgumentNullException(nameof(connector)); } protected override bool CanFinish() @@ -201,10 +195,7 @@ public ChangedOrNewOrderRule(Order order, IConnector connector) public ChangedOrNewOrderRule(Order order, IConnector connector, Func condition) : base(order, connector) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); Name = LocalizedStrings.Str1031; @@ -640,19 +631,10 @@ private sealed class PortfolioRule : MarketRule public PortfolioRule(Portfolio portfolio, IConnector connector, Func changed) : base(portfolio) { - if (portfolio == null) - throw new ArgumentNullException(nameof(portfolio)); - - if (connector == null) - throw new ArgumentNullException(nameof(connector)); + _changed = changed ?? throw new ArgumentNullException(nameof(changed)); - if (changed == null) - throw new ArgumentNullException(nameof(changed)); - - _changed = changed; - - _portfolio = portfolio; - _connector = connector; + _portfolio = portfolio ?? throw new ArgumentNullException(nameof(portfolio)); + _connector = connector ?? throw new ArgumentNullException(nameof(connector)); _connector.PortfolioChanged += OnPortfolioChanged; } @@ -751,19 +733,10 @@ public PositionRule(Position position, IConnector connector) public PositionRule(Position position, IConnector connector, Func changed) : base(position) { - if (position == null) - throw new ArgumentNullException(nameof(position)); - - if (connector == null) - throw new ArgumentNullException(nameof(connector)); + _changed = changed ?? throw new ArgumentNullException(nameof(changed)); - if (changed == null) - throw new ArgumentNullException(nameof(changed)); - - _changed = changed; - - _position = position; - _connector = connector; + _position = position ?? throw new ArgumentNullException(nameof(position)); + _connector = connector ?? throw new ArgumentNullException(nameof(connector)); _connector.PositionChanged += OnPositionChanged; } @@ -846,14 +819,8 @@ private abstract class SecurityRule : MarketRule protected SecurityRule(Security security, IConnector connector) : base(security) { - if (security == null) - throw new ArgumentNullException(nameof(security)); - - if (connector == null) - throw new ArgumentNullException(nameof(connector)); - - Security = security; - Connector = connector; + Security = security ?? throw new ArgumentNullException(nameof(security)); + Connector = connector ?? throw new ArgumentNullException(nameof(connector)); } protected Security Security { get; } @@ -874,10 +841,7 @@ public SecurityChangedRule(Security security, IConnector connector) public SecurityChangedRule(Security security, IConnector connector, Func condition) : base(security, connector) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); Name = LocalizedStrings.Str1046 + " " + security; Connector.SecurityChanged += OnSecurityChanged; @@ -967,10 +931,7 @@ private sealed class SecurityLastTradeRule : SecurityRule public SecurityLastTradeRule(Security security, IConnector connector, Func condition) : base(security, connector) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); Name = LocalizedStrings.Str1049 + " " + security; @@ -1371,10 +1332,7 @@ private abstract class MarketDepthRule : MarketRule protected MarketDepthRule(MarketDepth depth) : base(depth) { - if (depth == null) - throw new ArgumentNullException(nameof(depth)); - - Depth = depth; + Depth = depth ?? throw new ArgumentNullException(nameof(depth)); } protected MarketDepth Depth { get; } @@ -1392,10 +1350,7 @@ public MarketDepthChangedRule(MarketDepth depth) public MarketDepthChangedRule(MarketDepth depth, Func condition) : base(depth) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); Name = LocalizedStrings.Str1056 + " " + depth.Security; Depth.QuotesChanged += OnQuotesChanged; @@ -1559,10 +1514,7 @@ private abstract class BaseCandleSeriesRule : MarketRule : BaseCandleSeriesRule protected CandleSeriesRule(ICandleManager candleManager, CandleSeries series) : base(series) { - if (candleManager == null) - throw new ArgumentNullException(nameof(candleManager)); - - _candleManager = candleManager; + _candleManager = candleManager ?? throw new ArgumentNullException(nameof(candleManager)); _candleManager.Processing += OnProcessing; } @@ -1657,10 +1606,7 @@ public CandleChangedSeriesRule(ICandleManager candleManager, CandleSeries series public CandleChangedSeriesRule(ICandleManager candleManager, CandleSeries series, Func condition) : base(candleManager, series) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); Name = LocalizedStrings.Str1064 + " " + series; } @@ -1678,10 +1624,7 @@ private sealed class CurrentCandleSeriesRule : CandleSeriesRule public CurrentCandleSeriesRule(ICandleManager candleManager, CandleSeries series, Func condition) : base(candleManager, series) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); } protected override void OnProcessCandle(Candle candle) @@ -1698,10 +1641,7 @@ private abstract class CandleRule : MarketRule protected CandleRule(ICandleManager candleManager, Candle candle) : base(candle) { - if (candleManager == null) - throw new ArgumentNullException(nameof(candleManager)); - - _candleManager = candleManager; + _candleManager = candleManager ?? throw new ArgumentNullException(nameof(candleManager)); _candleManager.Processing += OnProcessing; Candle = candle; @@ -1738,10 +1678,7 @@ public ChangedCandleRule(ICandleManager candleManager, Candle candle) public ChangedCandleRule(ICandleManager candleManager, Candle candle, Func condition) : base(candleManager, candle) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); Name = LocalizedStrings.Str1065 + " " + candle; } @@ -2103,10 +2040,7 @@ private abstract class ConnectorRule : MarketRule protected ConnectorRule(IConnector connector) : base(connector) { - if (connector == null) - throw new ArgumentNullException(nameof(connector)); - - Connector = connector; + Connector = connector ?? throw new ArgumentNullException(nameof(connector)); } protected IConnector Connector { get; } diff --git a/Algo/MarketTimer.cs b/Algo/MarketTimer.cs index 9bcc563e78..b1cc7593d4 100644 --- a/Algo/MarketTimer.cs +++ b/Algo/MarketTimer.cs @@ -42,14 +42,8 @@ public class MarketTimer : Disposable /// The timer processor. public MarketTimer(IConnector connector, Action activated) { - if (connector == null) - throw new ArgumentNullException(nameof(connector)); - - if (activated == null) - throw new ArgumentNullException(nameof(activated)); - - _connector = connector; - _activated = activated; + _connector = connector ?? throw new ArgumentNullException(nameof(connector)); + _activated = activated ?? throw new ArgumentNullException(nameof(activated)); } /// diff --git a/Algo/OrderLogHelper.cs b/Algo/OrderLogHelper.cs index f22920a29b..dba946e5cd 100644 --- a/Algo/OrderLogHelper.cs +++ b/Algo/OrderLogHelper.cs @@ -175,9 +175,6 @@ private sealed class DepthEnumerator : IEnumerator public DepthEnumerator(IEnumerable items, IOrderLogMarketDepthBuilder builder, TimeSpan interval, int maxDepth) { - if (builder == null) - throw new ArgumentNullException(nameof(builder)); - if (items == null) throw new ArgumentNullException(nameof(items)); @@ -185,7 +182,7 @@ public DepthEnumerator(IEnumerable items, IOrderLogMarketDepth throw new ArgumentOutOfRangeException(nameof(maxDepth), maxDepth, LocalizedStrings.Str941); _itemsEnumerator = items.GetEnumerator(); - _builder = builder; + _builder = builder ?? throw new ArgumentNullException(nameof(builder)); _interval = interval; _maxDepth = maxDepth; } diff --git a/Algo/PnL/PnLInfo.cs b/Algo/PnL/PnLInfo.cs index 479be10584..2b1b3672df 100644 --- a/Algo/PnL/PnLInfo.cs +++ b/Algo/PnL/PnLInfo.cs @@ -33,13 +33,10 @@ public class PnLInfo /// The profit, realized by this trade. public PnLInfo(ExecutionMessage trade, decimal closedVolume, decimal pnL) { - if (trade == null) - throw new ArgumentNullException(nameof(trade)); - if (closedVolume < 0) throw new ArgumentOutOfRangeException(nameof(closedVolume), closedVolume, LocalizedStrings.Str946); - Trade = trade; + Trade = trade ?? throw new ArgumentNullException(nameof(trade)); ClosedVolume = closedVolume; PnL = pnL; } diff --git a/Algo/PnL/PnLMessageAdapter.cs b/Algo/PnL/PnLMessageAdapter.cs index 0ceabf1287..9d093160f0 100644 --- a/Algo/PnL/PnLMessageAdapter.cs +++ b/Algo/PnL/PnLMessageAdapter.cs @@ -41,13 +41,7 @@ public PnLMessageAdapter(IMessageAdapter innerAdapter) public IPnLManager PnLManager { get => _pnLManager; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _pnLManager = value; - } + set => _pnLManager = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/Positions/PositionMessageAdapter.cs b/Algo/Positions/PositionMessageAdapter.cs index adda2a9580..437ff1bd10 100644 --- a/Algo/Positions/PositionMessageAdapter.cs +++ b/Algo/Positions/PositionMessageAdapter.cs @@ -41,13 +41,7 @@ public PositionMessageAdapter(IMessageAdapter innerAdapter) public IPositionManager PositionManager { get => _positionManager; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _positionManager = value; - } + set => _positionManager = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/SecurityMappingMessageAdapter.cs b/Algo/SecurityMappingMessageAdapter.cs index 03c89e8ed5..71c920e835 100644 --- a/Algo/SecurityMappingMessageAdapter.cs +++ b/Algo/SecurityMappingMessageAdapter.cs @@ -29,10 +29,7 @@ public class SecurityMappingMessageAdapter : MessageAdapterWrapper public SecurityMappingMessageAdapter(IMessageAdapter innerAdapter, ISecurityMappingStorage storage) : base(innerAdapter) { - if (storage == null) - throw new ArgumentNullException(nameof(storage)); - - Storage = storage; + Storage = storage ?? throw new ArgumentNullException(nameof(storage)); Storage.Changed += OnStorageMappingChanged; } diff --git a/Algo/SecurityNativeIdMessageAdapter.cs b/Algo/SecurityNativeIdMessageAdapter.cs index be42dec9be..072c139f78 100644 --- a/Algo/SecurityNativeIdMessageAdapter.cs +++ b/Algo/SecurityNativeIdMessageAdapter.cs @@ -47,10 +47,7 @@ public ProcessSuspendedSecurityMessage(IMessageAdapter adapter, SecurityId secur public SecurityNativeIdMessageAdapter(IMessageAdapter innerAdapter, INativeIdStorage storage) : base(innerAdapter) { - if (storage == null) - throw new ArgumentNullException(nameof(storage)); - - Storage = storage; + Storage = storage ?? throw new ArgumentNullException(nameof(storage)); Storage.Added += OnStorageNewIdentifierAdded; } diff --git a/Algo/Slippage/SlippageMessageAdapter.cs b/Algo/Slippage/SlippageMessageAdapter.cs index 2788ab807b..7b22435fd6 100644 --- a/Algo/Slippage/SlippageMessageAdapter.cs +++ b/Algo/Slippage/SlippageMessageAdapter.cs @@ -41,13 +41,7 @@ public SlippageMessageAdapter(IMessageAdapter innerAdapter) public ISlippageManager SlippageManager { get => _slippageManager; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _slippageManager = value; - } + set => _slippageManager = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/Storages/BasketMarketDataStorage.cs b/Algo/Storages/BasketMarketDataStorage.cs index 91db7422e1..849963f8ab 100644 --- a/Algo/Storages/BasketMarketDataStorage.cs +++ b/Algo/Storages/BasketMarketDataStorage.cs @@ -77,10 +77,7 @@ private class BasketMarketDataStorageEnumerator : IEnumerator public BasketMarketDataStorageEnumerator(BasketMarketDataStorage storage, DateTime date) { - if (storage == null) - throw new ArgumentNullException(nameof(storage)); - - _storage = storage; + _storage = storage ?? throw new ArgumentNullException(nameof(storage)); _date = date; foreach (var s in storage._innerStorages.Cache) @@ -421,10 +418,7 @@ private class BasketMarketDataSerializer : IMarketDataSerializer public BasketMarketDataSerializer(BasketMarketDataStorage parent) { - if (parent == null) - throw new ArgumentNullException(nameof(parent)); - - _parent = parent; + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); } StorageFormats IMarketDataSerializer.Format => _parent.InnerStorages.First().Serializer.Format; diff --git a/Algo/Storages/Binary/BinaryMarketDataSerializer.cs b/Algo/Storages/Binary/BinaryMarketDataSerializer.cs index 0cdd56fb38..82a4d188d7 100644 --- a/Algo/Storages/Binary/BinaryMarketDataSerializer.cs +++ b/Algo/Storages/Binary/BinaryMarketDataSerializer.cs @@ -99,7 +99,7 @@ protected BinaryMetaInfo(DateTime date) public override object LastId { - get { return LastTime; } + get => LastTime; set { } } @@ -332,20 +332,11 @@ public class MarketDataEnumerator : SimpleEnumerator public MarketDataEnumerator(BinaryMarketDataSerializer serializer, BitArrayReader reader, TMetaInfo metaInfo) { - if (serializer == null) - throw new ArgumentNullException(nameof(serializer)); - - if (reader == null) - throw new ArgumentNullException(nameof(reader)); - - if (metaInfo == null) - throw new ArgumentNullException(nameof(metaInfo)); - - Serializer = serializer; + Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); Index = -1; - Reader = reader; + Reader = reader ?? throw new ArgumentNullException(nameof(reader)); - _originalMetaInfo = metaInfo; + _originalMetaInfo = metaInfo ?? throw new ArgumentNullException(nameof(metaInfo)); } public BitArrayReader Reader { get; } @@ -412,14 +403,11 @@ protected BinaryMarketDataSerializer(SecurityId securityId, int dataSize, Versio if (securityId == null) throw new ArgumentNullException(nameof(securityId)); - if (exchangeInfoProvider == null) - throw new ArgumentNullException(nameof(exchangeInfoProvider)); - SecurityId = securityId; DataSize = dataSize; Version = version; - ExchangeInfoProvider = exchangeInfoProvider; + ExchangeInfoProvider = exchangeInfoProvider ?? throw new ArgumentNullException(nameof(exchangeInfoProvider)); } protected SecurityId SecurityId { get; } diff --git a/Algo/Storages/Binary/CandleBinarySerializer.cs b/Algo/Storages/Binary/CandleBinarySerializer.cs index e1ffc4f09c..0e80e14baf 100644 --- a/Algo/Storages/Binary/CandleBinarySerializer.cs +++ b/Algo/Storages/Binary/CandleBinarySerializer.cs @@ -93,10 +93,7 @@ class CandleBinarySerializer : BinaryMarketDataSerializer candles, CandleMetaInfo metaInfo) diff --git a/Algo/Storages/CacheableMarketDataStorage.cs b/Algo/Storages/CacheableMarketDataStorage.cs index 22fadb7e3d..1862e3caa4 100644 --- a/Algo/Storages/CacheableMarketDataStorage.cs +++ b/Algo/Storages/CacheableMarketDataStorage.cs @@ -23,14 +23,8 @@ public class CacheableMarketDataStorage : IMarketDataStorage /// The cache-storage of market-data. public CacheableMarketDataStorage(IMarketDataStorage sourceStorage, IMarketDataStorage cacheStorage) { - if (sourceStorage == null) - throw new ArgumentNullException(nameof(sourceStorage)); - - if (cacheStorage == null) - throw new ArgumentNullException(nameof(cacheStorage)); - - _sourceStorage = sourceStorage; - _cacheStorage = cacheStorage; + _sourceStorage = sourceStorage ?? throw new ArgumentNullException(nameof(sourceStorage)); + _cacheStorage = cacheStorage ?? throw new ArgumentNullException(nameof(cacheStorage)); } IEnumerable IMarketDataStorage.Dates => _sourceStorage.Dates; diff --git a/Algo/Storages/Csv/CandleCsvSerializer.cs b/Algo/Storages/Csv/CandleCsvSerializer.cs index 5da14f1914..0cce44357f 100644 --- a/Algo/Storages/Csv/CandleCsvSerializer.cs +++ b/Algo/Storages/Csv/CandleCsvSerializer.cs @@ -50,11 +50,8 @@ private class CandleCsvMetaInfo : MetaInfo public CandleCsvMetaInfo(CandleCsvSerializer serializer, DateTime date, Encoding encoding) : base(date) { - if (encoding == null) - throw new ArgumentNullException(nameof(encoding)); - _serializer = serializer; - _encoding = encoding; + _encoding = encoding ?? throw new ArgumentNullException(nameof(encoding)); } public override object LastId { get; set; } @@ -129,10 +126,7 @@ public IEnumerable Process(IEnumerable messages) public CandleCsvSerializer(SecurityId securityId, object arg, Encoding encoding = null) : base(securityId, encoding) { - if (arg == null) - throw new ArgumentNullException(nameof(arg)); - - Arg = arg; + Arg = arg ?? throw new ArgumentNullException(nameof(arg)); } /// diff --git a/Algo/Storages/Csv/CsvMarketDataSerializer.cs b/Algo/Storages/Csv/CsvMarketDataSerializer.cs index c0e249874f..f36474907c 100644 --- a/Algo/Storages/Csv/CsvMarketDataSerializer.cs +++ b/Algo/Storages/Csv/CsvMarketDataSerializer.cs @@ -36,10 +36,7 @@ class CsvMetaInfo : MetaInfo public CsvMetaInfo(DateTime date, Encoding encoding, Func readId) : base(date) { - if (encoding == null) - throw new ArgumentNullException(nameof(encoding)); - - _encoding = encoding; + _encoding = encoding ?? throw new ArgumentNullException(nameof(encoding)); _readId = readId; } @@ -221,18 +218,9 @@ private class CsvEnumerator : SimpleEnumerator public CsvEnumerator(CsvMarketDataSerializer serializer, FastCsvReader reader, IMarketDataMetaInfo metaInfo) { - if (serializer == null) - throw new ArgumentNullException(nameof(serializer)); - - if (reader == null) - throw new ArgumentNullException(nameof(reader)); - - if (metaInfo == null) - throw new ArgumentNullException(nameof(metaInfo)); - - _serializer = serializer; - _reader = reader; - _metaInfo = metaInfo; + _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); + _reader = reader ?? throw new ArgumentNullException(nameof(reader)); + _metaInfo = metaInfo ?? throw new ArgumentNullException(nameof(metaInfo)); } public override bool MoveNext() diff --git a/Algo/Storages/EntityRegistry.cs b/Algo/Storages/EntityRegistry.cs index 840eae3b03..c5b28792c3 100644 --- a/Algo/Storages/EntityRegistry.cs +++ b/Algo/Storages/EntityRegistry.cs @@ -42,10 +42,7 @@ public EntityRegistry() /// The special interface for direct access to the storage. public EntityRegistry(IStorage storage) { - if (storage == null) - throw new ArgumentNullException(nameof(storage)); - - Storage = storage; + Storage = storage ?? throw new ArgumentNullException(nameof(storage)); ConfigManager.TryRegisterService(storage); diff --git a/Algo/Storages/IExtendedInfoStorage.cs b/Algo/Storages/IExtendedInfoStorage.cs index eab68b085a..b0716bcf8f 100644 --- a/Algo/Storages/IExtendedInfoStorage.cs +++ b/Algo/Storages/IExtendedInfoStorage.cs @@ -130,13 +130,10 @@ private class CsvExtendedInfoStorageItem : IExtendedInfoStorageItem public CsvExtendedInfoStorageItem(CsvExtendedInfoStorage storage, string fileName) { - if (storage == null) - throw new ArgumentNullException(nameof(storage)); - if (fileName.IsEmpty()) throw new ArgumentNullException(nameof(fileName)); - _storage = storage; + _storage = storage ?? throw new ArgumentNullException(nameof(storage)); _fileName = fileName; } @@ -339,13 +336,7 @@ public CsvExtendedInfoStorage(string path) public DelayAction DelayAction { get => _delayAction; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _delayAction = value; - } + set => _delayAction = value ?? throw new ArgumentNullException(nameof(value)); } IExtendedInfoStorageItem IExtendedInfoStorage.Create(string storageName, Tuple[] fields) diff --git a/Algo/Storages/INativeIdStorage.cs b/Algo/Storages/INativeIdStorage.cs index 283423e97e..503ea5a2de 100644 --- a/Algo/Storages/INativeIdStorage.cs +++ b/Algo/Storages/INativeIdStorage.cs @@ -96,13 +96,7 @@ public CsvNativeIdStorage(string path) public DelayAction DelayAction { get => _delayAction; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _delayAction = value; - } + set => _delayAction = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/Storages/ISecurityMappingStorage.cs b/Algo/Storages/ISecurityMappingStorage.cs index 8979e371e8..aeb9e4e690 100644 --- a/Algo/Storages/ISecurityMappingStorage.cs +++ b/Algo/Storages/ISecurityMappingStorage.cs @@ -210,13 +210,7 @@ public sealed class CsvSecurityMappingStorage : ISecurityMappingStorage public DelayAction DelayAction { get => _delayAction; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _delayAction = value; - } + set => _delayAction = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/Storages/ISecurityMarketDataDrive.cs b/Algo/Storages/ISecurityMarketDataDrive.cs index 07c6a1300f..023b2af9ac 100644 --- a/Algo/Storages/ISecurityMarketDataDrive.cs +++ b/Algo/Storages/ISecurityMarketDataDrive.cs @@ -442,14 +442,8 @@ DateTimeOffset IMarketDataStorageInfo.GetTime(MyTrade data) /// Security. public SecurityMarketDataDrive(IMarketDataDrive drive, Security security) { - if (drive == null) - throw new ArgumentNullException(nameof(drive)); - - if (security == null) - throw new ArgumentNullException(nameof(security)); - - Drive = drive; - Security = security; + Drive = drive ?? throw new ArgumentNullException(nameof(drive)); + Security = security ?? throw new ArgumentNullException(nameof(security)); SecurityId = security.ToSecurityId(); SecurityId.EnsureHashCode(); } @@ -498,13 +492,7 @@ private IMarketDataStorageDrive GetStorageDrive(IMarketDataSerializer serializer public IExchangeInfoProvider ExchangeInfoProvider { get => _exchangeInfoProvider; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _exchangeInfoProvider = value; - } + set => _exchangeInfoProvider = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/Storages/InMemoryMarketDataStorage.cs b/Algo/Storages/InMemoryMarketDataStorage.cs index 5964f004fe..ccaf498da9 100644 --- a/Algo/Storages/InMemoryMarketDataStorage.cs +++ b/Algo/Storages/InMemoryMarketDataStorage.cs @@ -58,12 +58,9 @@ public InMemoryMarketDataStorage(Security security, object arg, FuncHandler for retrieving in-memory data. public InMemoryMarketDataStorage(Security security, object arg, Func> getData) { - if (getData == null) - throw new ArgumentNullException(nameof(getData)); - _security = security; _arg = arg; - _getData = getData; + _getData = getData ?? throw new ArgumentNullException(nameof(getData)); } IEnumerable IMarketDataStorage.Dates => throw new NotSupportedException(); diff --git a/Algo/Storages/IndexSecurityMarketDataStorage.cs b/Algo/Storages/IndexSecurityMarketDataStorage.cs index dfc44bb18d..f2d30fc8da 100644 --- a/Algo/Storages/IndexSecurityMarketDataStorage.cs +++ b/Algo/Storages/IndexSecurityMarketDataStorage.cs @@ -125,13 +125,10 @@ public MessageBuffer(DateTimeOffset time, int maxMessageCount) public void AddMessage(int securityIndex, TBuffer msg) { - if (msg == null) - throw new ArgumentNullException(nameof(msg)); - //if (Messages[securityIndex] != null) // throw new ArgumentException(LocalizedStrings.Str654Params.Put(msg.LocalTime), nameof(msg)); - Messages[securityIndex] = msg; + Messages[securityIndex] = msg ?? throw new ArgumentNullException(nameof(msg)); } public void Fill(MessageBuffer prevBuffer) @@ -161,10 +158,7 @@ public void Fill(MessageBuffer prevBuffer) protected IndexBuilder(IndexSecurity security) { - if (security == null) - throw new ArgumentNullException(nameof(security)); - - Security = security; + Security = security ?? throw new ArgumentNullException(nameof(security)); SecurityId = security.ToSecurityId(); SecurityId.EnsureHashCode(); diff --git a/Algo/Storages/LocalMarketDataDrive.cs b/Algo/Storages/LocalMarketDataDrive.cs index 9842859603..3d5fc5c9ef 100644 --- a/Algo/Storages/LocalMarketDataDrive.cs +++ b/Algo/Storages/LocalMarketDataDrive.cs @@ -53,9 +53,6 @@ private sealed class LocalMarketDataStorageDrive : IMarketDataStorageDrive public LocalMarketDataStorageDrive(string fileName, string path, StorageFormats format, IMarketDataDrive drive) { - if (drive == null) - throw new ArgumentNullException(nameof(drive)); - if (fileName.IsEmpty()) throw new ArgumentNullException(nameof(fileName)); @@ -63,7 +60,7 @@ public LocalMarketDataStorageDrive(string fileName, string path, StorageFormats throw new ArgumentNullException(nameof(path)); _path = path; - _drive = drive; + _drive = drive ?? throw new ArgumentNullException(nameof(drive)); _fileNameWithExtension = fileName + GetExtension(format); _datesPath = IOPath.Combine(_path, fileName + format + "Dates.txt"); diff --git a/Algo/Storages/MarketDataStorage.cs b/Algo/Storages/MarketDataStorage.cs index 731bdceb7c..ace9327ef8 100644 --- a/Algo/Storages/MarketDataStorage.cs +++ b/Algo/Storages/MarketDataStorage.cs @@ -66,30 +66,15 @@ protected MarketDataStorage(SecurityId securityId, object arg, FuncThe storage of trade objects. public StorageEntityFactory(IEntityRegistry entityRegistry) { - if (entityRegistry == null) - throw new ArgumentNullException(nameof(entityRegistry)); - - _entityRegistry = entityRegistry; + _entityRegistry = entityRegistry ?? throw new ArgumentNullException(nameof(entityRegistry)); } /// diff --git a/Algo/Storages/StorageRegistry.cs b/Algo/Storages/StorageRegistry.cs index ff373b6d9d..800ca92f6a 100644 --- a/Algo/Storages/StorageRegistry.cs +++ b/Algo/Storages/StorageRegistry.cs @@ -904,13 +904,10 @@ private class SecurityStorage : Disposable, ISecurityStorage public SecurityStorage(StorageRegistry parent, IMarketDataDrive drive) { - if (parent == null) - throw new ArgumentNullException(nameof(parent)); - if (drive == null) throw new ArgumentNullException(nameof(drive)); - _parent = parent; + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); _file = Path.Combine(drive.Path, "instruments.csv"); Load(); } diff --git a/Algo/Strategies/Reporting/CsvStrategyReport.cs b/Algo/Strategies/Reporting/CsvStrategyReport.cs index 921e7cb3dc..94d1ead848 100644 --- a/Algo/Strategies/Reporting/CsvStrategyReport.cs +++ b/Algo/Strategies/Reporting/CsvStrategyReport.cs @@ -41,8 +41,6 @@ public class CsvStrategyReport : StrategyReport public CsvStrategyReport(Strategy strategy, string fileName) : this(new[] { strategy }, fileName) { - if (strategy == null) - throw new ArgumentNullException(nameof(strategy)); } /// @@ -72,12 +70,12 @@ public override void Generate() var parameters = strategy.Parameters.CachedValues; WriteValues(writer, LocalizedStrings.Str1322); WriteValues(writer, parameters.Select(p => (object)p.Name).ToArray()); - WriteValues(writer, parameters.Select(p => p.Value is TimeSpan ? Format((TimeSpan)p.Value) : p.Value).ToArray()); + WriteValues(writer, parameters.Select(p => p.Value is TimeSpan ts ? Format(ts) : p.Value).ToArray()); var statParameters = strategy.StatisticManager.Parameters.SyncGet(c => c.ToArray()); WriteValues(writer, LocalizedStrings.Str436); WriteValues(writer, statParameters.Select(p => (object)p.Name).ToArray()); - WriteValues(writer, statParameters.Select(p => p.Value is TimeSpan ? Format((TimeSpan)p.Value) : p.Value).ToArray()); + WriteValues(writer, statParameters.Select(p => p.Value is TimeSpan ts ? Format(ts) : p.Value).ToArray()); WriteValues(writer, LocalizedStrings.Orders); WriteValues(writer, LocalizedStrings.Str1190, LocalizedStrings.Transaction, LocalizedStrings.Str128, LocalizedStrings.Time, LocalizedStrings.Price, diff --git a/Algo/Strategies/Reporting/XmlStrategyReport.cs b/Algo/Strategies/Reporting/XmlStrategyReport.cs index 03a4c68a1d..5a6b994c29 100644 --- a/Algo/Strategies/Reporting/XmlStrategyReport.cs +++ b/Algo/Strategies/Reporting/XmlStrategyReport.cs @@ -66,7 +66,7 @@ public override void Generate() strategy.Parameters.CachedValues.Select(p => new XElement("parameter", new XElement("name", p.Name), - new XElement("value", p.Value is TimeSpan ? Format((TimeSpan)p.Value) : p.Value) + new XElement("value", p.Value is TimeSpan ts ? Format(ts) : p.Value) ))), new XElement("totalWorkingTime", Format(strategy.TotalWorkingTime)), new XElement("commission", strategy.Commission), @@ -78,7 +78,7 @@ public override void Generate() strategy.StatisticManager.Parameters.SyncGet(c => c.ToArray()).Select(p => new XElement("parameter", new XElement("name", p.Name), - new XElement("value", p.Value is TimeSpan ? Format((TimeSpan)p.Value) : p.Value) + new XElement("value", p.Value is TimeSpan ts ? Format(ts) : p.Value) ))), new XElement("orders", strategy.Orders.OrderBy(o => o.TransactionId).Select(o => diff --git a/Algo/Strategies/Strategy.cs b/Algo/Strategies/Strategy.cs index 388dad9368..0bd3584f79 100644 --- a/Algo/Strategies/Strategy.cs +++ b/Algo/Strategies/Strategy.cs @@ -62,7 +62,7 @@ static Strategy() MemoryStatistics.Instance.Values.Add(_strategyStat); } - sealed class ChildStrategyList : SynchronizedSet, IStrategyChildStrategyList + private sealed class ChildStrategyList : SynchronizedSet, IStrategyChildStrategyList { private readonly Dictionary _childStrategyRules = new Dictionary(); private readonly Strategy _parent; @@ -70,10 +70,7 @@ sealed class ChildStrategyList : SynchronizedSet, IStrategyChildStrate public ChildStrategyList(Strategy parent) : base(true) { - if (parent == null) - throw new ArgumentNullException(nameof(parent)); - - _parent = parent; + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); } protected override void OnAdded(Strategy item) @@ -201,10 +198,7 @@ private sealed class StrategyRuleList : MarketRuleList public StrategyRuleList(Strategy strategy) : base(strategy) { - if (strategy == null) - throw new ArgumentNullException(nameof(strategy)); - - _strategy = strategy; + _strategy = strategy ?? throw new ArgumentNullException(nameof(strategy)); } protected override bool OnAdding(IMarketRule item) @@ -492,13 +486,7 @@ public virtual Security Security public IPnLManager PnLManager { get => _pnLManager; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _pnLManager = value; - } + set => _pnLManager = value ?? throw new ArgumentNullException(nameof(value)); } /// @@ -656,13 +644,7 @@ event Action IPositionProvider.PositionChanged public StatisticManager StatisticManager { get => _statisticManager; - protected set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _statisticManager = value; - } + protected set => _statisticManager = value ?? throw new ArgumentNullException(nameof(value)); } private IRiskManager _riskManager; @@ -674,13 +656,7 @@ protected set public IRiskManager RiskManager { get => _riskManager; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _riskManager = value; - } + set => _riskManager = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/Strategies/StrategyHelper.cs b/Algo/Strategies/StrategyHelper.cs index 00077a1279..95828a70d2 100644 --- a/Algo/Strategies/StrategyHelper.cs +++ b/Algo/Strategies/StrategyHelper.cs @@ -484,10 +484,7 @@ private abstract class StrategyRule : MarketRule protected StrategyRule(Strategy strategy) : base(strategy) { - if (strategy == null) - throw new ArgumentNullException(nameof(strategy)); - - Strategy = strategy; + Strategy = strategy ?? throw new ArgumentNullException(nameof(strategy)); } protected Strategy Strategy { get; } @@ -506,10 +503,7 @@ public PnLManagerStrategyRule(Strategy strategy) public PnLManagerStrategyRule(Strategy strategy, Func changed) : base(strategy) { - if (changed == null) - throw new ArgumentNullException(nameof(changed)); - - _changed = changed; + _changed = changed ?? throw new ArgumentNullException(nameof(changed)); Strategy.PnLChanged += OnPnLChanged; } @@ -540,10 +534,7 @@ public PositionManagerStrategyRule(Strategy strategy) public PositionManagerStrategyRule(Strategy strategy, Func changed) : base(strategy) { - if (changed == null) - throw new ArgumentNullException(nameof(changed)); - - _changed = changed; + _changed = changed ?? throw new ArgumentNullException(nameof(changed)); Strategy.PositionChanged += OnPositionChanged; } @@ -625,10 +616,7 @@ private sealed class ProcessStateChangedStrategyRule : StrategyRule public ProcessStateChangedStrategyRule(Strategy strategy, Func condition) : base(strategy) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); Strategy.ProcessStateChanged += OnProcessStateChanged; } @@ -653,10 +641,7 @@ private sealed class PropertyChangedStrategyRule : StrategyRule public PropertyChangedStrategyRule(Strategy strategy, Func condition) : base(strategy) { - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - _condition = condition; + _condition = condition ?? throw new ArgumentNullException(nameof(condition)); Strategy.PropertyChanged += OnPropertyChanged; } diff --git a/Algo/Strategies/StrategyNameGenerator.cs b/Algo/Strategies/StrategyNameGenerator.cs index 032ad0d8ad..25af91616c 100644 --- a/Algo/Strategies/StrategyNameGenerator.cs +++ b/Algo/Strategies/StrategyNameGenerator.cs @@ -73,10 +73,7 @@ bool ISource.TryEvaluateSelector(ISelectorInfo selectorInfo) /// Strategy. public StrategyNameGenerator(Strategy strategy) { - if (strategy == null) - throw new ArgumentNullException(nameof(strategy)); - - _strategy = strategy; + _strategy = strategy ?? throw new ArgumentNullException(nameof(strategy)); _strategy.SecurityChanged += () => { if (_selectors.Contains("Security")) diff --git a/Algo/Strategies/StrategyParam.cs b/Algo/Strategies/StrategyParam.cs index a9978febbe..24f7b2a6b0 100644 --- a/Algo/Strategies/StrategyParam.cs +++ b/Algo/Strategies/StrategyParam.cs @@ -110,16 +110,13 @@ public StrategyParam(Strategy strategy, string name, T initialValue) /// The initial value. public StrategyParam(Strategy strategy, string id, string name, T initialValue) { - if (strategy == null) - throw new ArgumentNullException(nameof(strategy)); - if (id.IsEmpty()) throw new ArgumentNullException(nameof(id)); if (name.IsEmpty()) throw new ArgumentNullException(nameof(name)); - _strategy = strategy; + _strategy = strategy ?? throw new ArgumentNullException(nameof(strategy)); Id = id; Name = name; _value = initialValue; diff --git a/Algo/SubscriptionMessageAdapter.cs b/Algo/SubscriptionMessageAdapter.cs index a95a8bcc6e..293d67a8c4 100644 --- a/Algo/SubscriptionMessageAdapter.cs +++ b/Algo/SubscriptionMessageAdapter.cs @@ -27,10 +27,7 @@ private sealed class SubscriptionInfo public SubscriptionInfo(MarketDataMessage message) { - if (message == null) - throw new ArgumentNullException(nameof(message)); - - Message = message; + Message = message ?? throw new ArgumentNullException(nameof(message)); Subscriptions = new List(); } } diff --git a/Algo/Testing/ExecutionLogConverter.cs b/Algo/Testing/ExecutionLogConverter.cs index 0c1b166391..22e86d8c27 100644 --- a/Algo/Testing/ExecutionLogConverter.cs +++ b/Algo/Testing/ExecutionLogConverter.cs @@ -59,22 +59,10 @@ public ExecutionLogConverter(SecurityId securityId, SortedDictionary> asks, MarketEmulatorSettings settings, Func getServerTime) { - if (bids == null) - throw new ArgumentNullException(nameof(bids)); - - if (asks == null) - throw new ArgumentNullException(nameof(asks)); - - if (settings == null) - throw new ArgumentNullException(nameof(settings)); - - if (getServerTime == null) - throw new ArgumentNullException(nameof(getServerTime)); - - _bids = bids; - _asks = asks; - _settings = settings; - _getServerTime = getServerTime; + _bids = bids ?? throw new ArgumentNullException(nameof(bids)); + _asks = asks ?? throw new ArgumentNullException(nameof(asks)); + _settings = settings ?? throw new ArgumentNullException(nameof(settings)); + _getServerTime = getServerTime ?? throw new ArgumentNullException(nameof(getServerTime)); SecurityId = securityId; } @@ -771,10 +759,7 @@ private decimal GetPriceStep() public void UpdateSecurityDefinition(SecurityMessage securityDefinition) { - if (securityDefinition == null) - throw new ArgumentNullException(nameof(securityDefinition)); - - _securityDefinition = securityDefinition; + _securityDefinition = securityDefinition ?? throw new ArgumentNullException(nameof(securityDefinition)); _priceStepUpdated = _securityDefinition.PriceStep != null; _volumeStepUpdated = _securityDefinition.VolumeStep != null; diff --git a/Algo/Testing/HistoryEmulationConnector.cs b/Algo/Testing/HistoryEmulationConnector.cs index 4ed566fc53..60a956ecd7 100644 --- a/Algo/Testing/HistoryEmulationConnector.cs +++ b/Algo/Testing/HistoryEmulationConnector.cs @@ -117,14 +117,8 @@ private sealed class HistoryEmulationMessageChannel : Cloneable public HistoryEmulationMessageChannel(HistoryMessageAdapter historyMessageAdapter, Action errorHandler) { - if (historyMessageAdapter == null) - throw new ArgumentNullException(nameof(historyMessageAdapter)); - - if (errorHandler == null) - throw new ArgumentNullException(nameof(errorHandler)); - - _historyMessageAdapter = historyMessageAdapter; - _errorHandler = errorHandler; + _historyMessageAdapter = historyMessageAdapter ?? throw new ArgumentNullException(nameof(historyMessageAdapter)); + _errorHandler = errorHandler ?? throw new ArgumentNullException(nameof(errorHandler)); _messageQueue.Close(); } diff --git a/Algo/Testing/MarketDataGenerator.cs b/Algo/Testing/MarketDataGenerator.cs index 19a400ba85..bba749f981 100644 --- a/Algo/Testing/MarketDataGenerator.cs +++ b/Algo/Testing/MarketDataGenerator.cs @@ -193,13 +193,7 @@ public RandomArray Volumes return _volumes; } - protected set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _volumes = value; - } + protected set => _volumes = value ?? throw new ArgumentNullException(nameof(value)); } private RandomArray _steps; @@ -216,13 +210,7 @@ public RandomArray Steps return _steps; } - protected set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _steps = value; - } + protected set => _steps = value ?? throw new ArgumentNullException(nameof(value)); } } } \ No newline at end of file diff --git a/Algo/Testing/MarketEmulator.cs b/Algo/Testing/MarketEmulator.cs index 51d5938d60..236b9d939f 100644 --- a/Algo/Testing/MarketEmulator.cs +++ b/Algo/Testing/MarketEmulator.cs @@ -149,10 +149,7 @@ private sealed class SecurityMarketEmulator : BaseLogReceiver//, IMarketEmulator public SecurityMarketEmulator(MarketEmulator parent, SecurityId securityId) { - if (parent == null) - throw new ArgumentNullException(nameof(parent)); - - _parent = parent; + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); _securityId = securityId; _execLogConverter = new ExecutionLogConverter(securityId, _bids, _asks, _parent.Settings, GetServerTime); } diff --git a/Algo/Testing/OrderLogGenerator.cs b/Algo/Testing/OrderLogGenerator.cs index 62879f8601..205effa9cd 100644 --- a/Algo/Testing/OrderLogGenerator.cs +++ b/Algo/Testing/OrderLogGenerator.cs @@ -48,12 +48,9 @@ public OrderLogGenerator(SecurityId securityId) public OrderLogGenerator(SecurityId securityId, TradeGenerator tradeGenerator) : base(securityId) { - if (tradeGenerator == null) - throw new ArgumentNullException(nameof(tradeGenerator)); - //_lastOrderPrice = startPrice; - TradeGenerator = tradeGenerator; + TradeGenerator = tradeGenerator ?? throw new ArgumentNullException(nameof(tradeGenerator)); IdGenerator = new IncrementalIdGenerator(); } @@ -75,13 +72,7 @@ public OrderLogGenerator(SecurityId securityId, TradeGenerator tradeGenerator) public IdGenerator IdGenerator { get => _idGenerator; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _idGenerator = value; - } + set => _idGenerator = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Algo/Testing/RealTimeEmulationTrader.cs b/Algo/Testing/RealTimeEmulationTrader.cs index c59f338e4b..6f72dbf2d5 100644 --- a/Algo/Testing/RealTimeEmulationTrader.cs +++ b/Algo/Testing/RealTimeEmulationTrader.cs @@ -214,18 +214,12 @@ public RealTimeEmulationTrader(TUnderlyingMarketDataAdapter underlyngMarketDataA /// Track the connection lifetime. public RealTimeEmulationTrader(TUnderlyingMarketDataAdapter underlyngMarketDataAdapter, Portfolio portfolio, bool ownAdapter = true) { - if (underlyngMarketDataAdapter == null) - throw new ArgumentNullException(nameof(underlyngMarketDataAdapter)); - - if (portfolio == null) - throw new ArgumentNullException(nameof(portfolio)); - - UnderlyngMarketDataAdapter = underlyngMarketDataAdapter; + UnderlyngMarketDataAdapter = underlyngMarketDataAdapter ?? throw new ArgumentNullException(nameof(underlyngMarketDataAdapter)); UpdateSecurityByLevel1 = false; UpdateSecurityLastQuotes = false; - _portfolio = portfolio; + _portfolio = portfolio ?? throw new ArgumentNullException(nameof(portfolio)); EntityFactory = new EmulationEntityFactory(_portfolio); _ownAdapter = ownAdapter; diff --git a/Algo/Testing/TradeGenerator.cs b/Algo/Testing/TradeGenerator.cs index 2c93222e9e..2bf356c883 100644 --- a/Algo/Testing/TradeGenerator.cs +++ b/Algo/Testing/TradeGenerator.cs @@ -51,13 +51,7 @@ protected TradeGenerator(SecurityId securityId) public IdGenerator IdGenerator { get => _idGenerator; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _idGenerator = value; - } + set => _idGenerator = value ?? throw new ArgumentNullException(nameof(value)); } } diff --git a/Algo/TraderHelper.cs b/Algo/TraderHelper.cs index 8909240248..e7a345c0c0 100644 --- a/Algo/TraderHelper.cs +++ b/Algo/TraderHelper.cs @@ -2213,10 +2213,7 @@ private sealed class NativePositionManager : IPositionManager public NativePositionManager(Position position) { - if (position == null) - throw new ArgumentNullException(nameof(position)); - - _position = position; + _position = position ?? throw new ArgumentNullException(nameof(position)); } /// @@ -3952,10 +3949,7 @@ private class TickEnumerator : IEnumerator public TickEnumerator(IEnumerator level1Enumerator) { - if (level1Enumerator == null) - throw new ArgumentNullException(nameof(level1Enumerator)); - - _level1Enumerator = level1Enumerator; + _level1Enumerator = level1Enumerator ?? throw new ArgumentNullException(nameof(level1Enumerator)); } public ExecutionMessage Current { get; private set; } @@ -4066,10 +4060,7 @@ private class OrderBookEnumerator : IEnumerator public OrderBookEnumerator(IEnumerator level1Enumerator) { - if (level1Enumerator == null) - throw new ArgumentNullException(nameof(level1Enumerator)); - - _level1Enumerator = level1Enumerator; + _level1Enumerator = level1Enumerator ?? throw new ArgumentNullException(nameof(level1Enumerator)); } public QuoteChangeMessage Current { get; private set; } diff --git a/BusinessEntities/AggregatedQuote.cs b/BusinessEntities/AggregatedQuote.cs index 3137c91168..91abb1f02f 100644 --- a/BusinessEntities/AggregatedQuote.cs +++ b/BusinessEntities/AggregatedQuote.cs @@ -37,10 +37,7 @@ private sealed class InnerQuotesList : BaseList public InnerQuotesList(AggregatedQuote parent) { - if (parent == null) - throw new ArgumentNullException(nameof(parent)); - - _parent = parent; + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); } protected override bool OnAdding(Quote item) diff --git a/BusinessEntities/Exchange.cs b/BusinessEntities/Exchange.cs index c5da4d20e0..38c88e364f 100644 --- a/BusinessEntities/Exchange.cs +++ b/BusinessEntities/Exchange.cs @@ -142,10 +142,7 @@ public IDictionary ExtensionInfo get => _extensionInfo; set { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _extensionInfo = value; + _extensionInfo = value ?? throw new ArgumentNullException(nameof(value)); Notify(nameof(ExtensionInfo)); } } diff --git a/BusinessEntities/ExchangeBoard.cs b/BusinessEntities/ExchangeBoard.cs index dc6a578d4d..2282f5bc1b 100644 --- a/BusinessEntities/ExchangeBoard.cs +++ b/BusinessEntities/ExchangeBoard.cs @@ -83,13 +83,10 @@ public string Code get => _code; set { - if (value == null) - throw new ArgumentNullException(nameof(value)); - if (Code == value) return; - _code = value; + _code = value ?? throw new ArgumentNullException(nameof(value)); Notify(nameof(Code)); } } @@ -195,13 +192,10 @@ public WorkingTime WorkingTime get => _workingTime; set { - if (value == null) - throw new ArgumentNullException(nameof(value)); - if (WorkingTime == value) return; - _workingTime = value; + _workingTime = value ?? throw new ArgumentNullException(nameof(value)); Notify(nameof(WorkingTime)); } } @@ -220,13 +214,10 @@ public TimeZoneInfo TimeZone get => _timeZone; set { - if (value == null) - throw new ArgumentNullException(nameof(value)); - if (TimeZone == value) return; - _timeZone = value; + _timeZone = value ?? throw new ArgumentNullException(nameof(value)); Notify(nameof(TimeZone)); } } @@ -260,10 +251,7 @@ public IDictionary ExtensionInfo get => _extensionInfo; set { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _extensionInfo = value; + _extensionInfo = value ?? throw new ArgumentNullException(nameof(value)); Notify(nameof(ExtensionInfo)); } } diff --git a/BusinessEntities/MarketDepthPair.cs b/BusinessEntities/MarketDepthPair.cs index e587c3a2f2..16147fa815 100644 --- a/BusinessEntities/MarketDepthPair.cs +++ b/BusinessEntities/MarketDepthPair.cs @@ -39,16 +39,13 @@ public class MarketDepthPair /// Ask. public MarketDepthPair(Security security, Quote bid, Quote ask) { - if (security == null) - throw new ArgumentNullException(nameof(security)); - if (bid != null && bid.OrderDirection != Sides.Buy) throw new ArgumentException(LocalizedStrings.Str492, nameof(bid)); if (ask != null && ask.OrderDirection != Sides.Sell) throw new ArgumentException(LocalizedStrings.Str493, nameof(ask)); - Security = security; + Security = security ?? throw new ArgumentNullException(nameof(security)); Bid = bid; Ask = ask; diff --git a/Logging/ExternalLogListener.cs b/Logging/ExternalLogListener.cs index 2969298882..ed6338318a 100644 --- a/Logging/ExternalLogListener.cs +++ b/Logging/ExternalLogListener.cs @@ -29,10 +29,7 @@ public class ExternalLogListener : LogListener /// External recipient of messages. public ExternalLogListener(ILogListener logger) { - if (logger == null) - throw new ArgumentNullException(nameof(logger)); - - Logger = logger; + Logger = logger ?? throw new ArgumentNullException(nameof(logger)); } /// diff --git a/Logging/FileLogListener.cs b/Logging/FileLogListener.cs index cf9805a557..fce7c22d65 100644 --- a/Logging/FileLogListener.cs +++ b/Logging/FileLogListener.cs @@ -117,13 +117,7 @@ public string FileName public Encoding Encoding { get => _encoding; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _encoding = value; - } + set => _encoding = value ?? throw new ArgumentNullException(nameof(value)); } private long _maxLength; diff --git a/Logging/LogManager.cs b/Logging/LogManager.cs index 1e67ff9431..f5a23c103e 100644 --- a/Logging/LogManager.cs +++ b/Logging/LogManager.cs @@ -57,10 +57,7 @@ private sealed class LogSourceList : BaseList public LogSourceList(LogManager parent) { - if (parent == null) - throw new ArgumentNullException(nameof(parent)); - - _parent = parent; + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); } protected override bool OnAdding(ILogSource item) diff --git a/Logging/LogMessage.cs b/Logging/LogMessage.cs index ca361f9462..5464b73603 100644 --- a/Logging/LogMessage.cs +++ b/Logging/LogMessage.cs @@ -50,15 +50,8 @@ public LogMessage(ILogSource source, DateTimeOffset time, LogLevels level, strin /// The function returns the text for . public LogMessage(ILogSource source, DateTimeOffset time, LogLevels level, Func getMessage) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - if (getMessage == null) - throw new ArgumentNullException(nameof(getMessage)); - - _getMessage = getMessage; - - Source = source; + Source = source ?? throw new ArgumentNullException(nameof(source)); + _getMessage = getMessage ?? throw new ArgumentNullException(nameof(getMessage)); Time = time; Level = level; } diff --git a/Logging/TraceSource.cs b/Logging/TraceSource.cs index 8e8b34ba69..b5c5a5e604 100644 --- a/Logging/TraceSource.cs +++ b/Logging/TraceSource.cs @@ -33,10 +33,7 @@ private class TraceListenerEx : TraceListener public TraceListenerEx(TraceSource source) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - _source = source; + _source = source ?? throw new ArgumentNullException(nameof(source)); } public override void Write(string message) diff --git a/Messages/CandleMessageVolumeProfile.cs b/Messages/CandleMessageVolumeProfile.cs index 2acc695944..9b660bab78 100644 --- a/Messages/CandleMessageVolumeProfile.cs +++ b/Messages/CandleMessageVolumeProfile.cs @@ -44,10 +44,7 @@ public CandleMessageVolumeProfile() /// Price levels. public CandleMessageVolumeProfile(IList priceLevels) { - if (priceLevels == null) - throw new ArgumentNullException(nameof(priceLevels)); - - PriceLevels = priceLevels; + PriceLevels = priceLevels ?? throw new ArgumentNullException(nameof(priceLevels)); } /// diff --git a/Messages/ChannelMessageAdapter.cs b/Messages/ChannelMessageAdapter.cs index 53605733ab..99a877e7b1 100644 --- a/Messages/ChannelMessageAdapter.cs +++ b/Messages/ChannelMessageAdapter.cs @@ -31,14 +31,8 @@ public class ChannelMessageAdapter : MessageAdapterWrapper, IMessageSender public ChannelMessageAdapter(IMessageAdapter innerAdapter, IMessageChannel inputChannel, IMessageChannel outputChannel) : base(innerAdapter) { - if (inputChannel == null) - throw new ArgumentNullException(nameof(inputChannel)); - - if (outputChannel == null) - throw new ArgumentNullException(nameof(outputChannel)); - - InputChannel = inputChannel; - OutputChannel = outputChannel; + InputChannel = inputChannel ?? throw new ArgumentNullException(nameof(inputChannel)); + OutputChannel = outputChannel ?? throw new ArgumentNullException(nameof(outputChannel)); InputChannel.NewOutMessage += InputChannelOnNewOutMessage; OutputChannel.NewOutMessage += OutputChannelOnNewOutMessage; diff --git a/Messages/IMessageAdapterWrapper.cs b/Messages/IMessageAdapterWrapper.cs index 82e12ceac8..38f148055a 100644 --- a/Messages/IMessageAdapterWrapper.cs +++ b/Messages/IMessageAdapterWrapper.cs @@ -47,10 +47,7 @@ public abstract class MessageAdapterWrapper : Cloneable, IMessa /// Underlying adapter. protected MessageAdapterWrapper(IMessageAdapter innerAdapter) { - if (innerAdapter == null) - throw new ArgumentNullException(nameof(innerAdapter)); - - InnerAdapter = innerAdapter; + InnerAdapter = innerAdapter ?? throw new ArgumentNullException(nameof(innerAdapter)); } /// diff --git a/Messages/QuoteChangeMessage.cs b/Messages/QuoteChangeMessage.cs index 113eada000..066d7bda12 100644 --- a/Messages/QuoteChangeMessage.cs +++ b/Messages/QuoteChangeMessage.cs @@ -53,13 +53,7 @@ public sealed class QuoteChangeMessage : Message public IEnumerable Bids { get => _bids; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _bids = value; - } + set => _bids = value ?? throw new ArgumentNullException(nameof(value)); } private IEnumerable _asks = Enumerable.Empty(); @@ -74,13 +68,7 @@ public IEnumerable Bids public IEnumerable Asks { get => _asks; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _asks = value; - } + set => _asks = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Messages/ReConnectionSettings.cs b/Messages/ReConnectionSettings.cs index 518e78f45f..9e0930e33b 100644 --- a/Messages/ReConnectionSettings.cs +++ b/Messages/ReConnectionSettings.cs @@ -128,13 +128,7 @@ public TimeSpan TimeOutInterval public WorkingTime WorkingTime { get => _workingTime; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _workingTime = value; - } + set => _workingTime = value ?? throw new ArgumentNullException(nameof(value)); } /// diff --git a/Messages/WorkingTime.cs b/Messages/WorkingTime.cs index a05d9f64dc..a9ec54ada6 100644 --- a/Messages/WorkingTime.cs +++ b/Messages/WorkingTime.cs @@ -55,13 +55,7 @@ public WorkingTime() public List Periods { get => _periods; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _periods = value; - } + set => _periods = value ?? throw new ArgumentNullException(nameof(value)); } private List _specialWorkingDays = new List(); diff --git a/Messages/WorkingTimePeriod.cs b/Messages/WorkingTimePeriod.cs index a2dd4f4b6b..b6ba207867 100644 --- a/Messages/WorkingTimePeriod.cs +++ b/Messages/WorkingTimePeriod.cs @@ -72,13 +72,7 @@ public override object CreateInstance() public List> Times { get => _times; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - _times = value; - } + set => _times = value ?? throw new ArgumentNullException(nameof(value)); } ///