private void UpdateProvider(ISecurityProvider provider) { if (_securityProvider == provider) return; if (_securityProvider != null) { _securityProvider.Added -= AddSecurities; _securityProvider.Removed -= RemoveSecurities; _securityProvider.Cleared -= ClearSecurities; SecurityTextBox.ItemsSource = Enumerable.Empty<Security>(); _itemsSource = null; } _securityProvider = provider; if (_securityProvider == null) return; var itemsSource = new ObservableCollectionEx<Security>(); _itemsSource = new ThreadSafeObservableCollection<Security>(itemsSource); _itemsSource.AddRange(_securityProvider.LookupAll()); _securityProvider.Added += AddSecurities; _securityProvider.Removed += RemoveSecurities; _securityProvider.Cleared += ClearSecurities; SecurityTextBox.ItemsSource = itemsSource; }
/// <inheritdoc /> protected override bool OnSendInMessage(Message message) { switch (message.Type) { case MessageTypes.Reset: { _subscriptions.Clear(); break; } case MessageTypes.SecurityLookup: { if (_securityProvider != null) { var lookupMsg = (SecurityLookupMessage)message; var securities = lookupMsg.SecurityId == default ? _securityProvider.LookupAll() : _securityProvider.Lookup(lookupMsg); foreach (var security in securities) { SendOutMessage(security.Board.ToMessage()); SendOutMessage(security.ToMessage(originalTransactionId: lookupMsg.TransactionId)); } SendOutMessage(new SubscriptionFinishedMessage { OriginalTransactionId = lookupMsg.TransactionId }); return(true); } break; } case MessageTypes.MarketData: { var mdMsg = (MarketDataMessage)message; if (mdMsg.IsSubscribe) { _subscriptions.Add(mdMsg.TransactionId); } break; } case ExtendedMessageTypes.EmulationState: SendOutMessage(message); return(true); } return(base.OnSendInMessage(message)); }
/// <summary> /// Initializes a new instance of the <see cref="HistoryMessageAdapter"/>. /// </summary> /// <param name="transactionIdGenerator">Transaction id generator.</param> /// <param name="securityProvider">The provider of information about instruments.</param> public HistoryMessageAdapter(IdGenerator transactionIdGenerator, ISecurityProvider securityProvider) : this(transactionIdGenerator) { SecurityProvider = securityProvider; BasketStorage.Boards = SecurityProvider .LookupAll() .Select(s => s.Board) .Distinct(); this.AddMarketDataSupport(); this.AddSupportedMessage(ExtendedMessageTypes.EmulationState); this.AddSupportedMessage(ExtendedMessageTypes.HistorySource); }
/// <summary> /// Initializes a new instance of the <see cref="FilterableSecurityProvider"/>. /// </summary> /// <param name="provider">Security meta info provider.</param> /// <param name="ownProvider"><see langword="true"/> to leave the <paramref name="provider"/> open after the <see cref="FilterableSecurityProvider"/> object is disposed; otherwise, <see langword="false"/>.</param> ///// <param name="excludeFilter">Filter for instruments exclusion.</param> public FilterableSecurityProvider(ISecurityProvider provider, bool ownProvider = false /*, Func<Security, bool> excludeFilter = null*/) { _provider = provider ?? throw new ArgumentNullException(nameof(provider)); _ownProvider = ownProvider; //ExcludeFilter = excludeFilter; _provider.Added += AddSecurities; _provider.Removed += RemoveSecurities; _provider.Cleared += ClearSecurities; AddSecurities(_provider.LookupAll()); }
/// <summary> /// Initializes a new instance of the <see cref="FilterableSecurityProvider"/>. /// </summary> /// <param name="provider">Security meta info provider.</param> /// <param name="ownProvider"><see langword="true"/> to leave the <paramref name="provider"/> open after the <see cref="FilterableSecurityProvider"/> object is disposed; otherwise, <see langword="false"/>.</param> ///// <param name="excludeFilter">Filter for instruments exclusion.</param> public FilterableSecurityProvider(ISecurityProvider provider, bool ownProvider = false/*, Func<Security, bool> excludeFilter = null*/) { if (provider == null) throw new ArgumentNullException(nameof(provider)); _provider = provider; _ownProvider = ownProvider; //ExcludeFilter = excludeFilter; _provider.Added += AddSecurities; _provider.Removed += RemoveSecurities; _provider.Cleared += ClearSecurities; AddSecurities(_provider.LookupAll()); }
/// <summary> /// Initializes a new instance of the <see cref="FilterableSecurityProvider"/>. /// </summary> /// <param name="provider">Security meta info provider.</param> /// <param name="ownProvider"><see langword="true"/> to leave the <paramref name="provider"/> open after the <see cref="FilterableSecurityProvider"/> object is disposed; otherwise, <see langword="false"/>.</param> ///// <param name="excludeFilter">Filter for instruments exclusion.</param> public FilterableSecurityProvider(ISecurityProvider provider, bool ownProvider = false /*, Func<Security, bool> excludeFilter = null*/) { if (provider == null) { throw new ArgumentNullException("provider"); } _provider = provider; _ownProvider = ownProvider; //ExcludeFilter = excludeFilter; _provider.Added += AddSecurity; _provider.Removed += RemoveSecurity; _provider.Cleared += ClearSecurities; _provider.LookupAll().ForEach(AddSecurity); }