public AdaptersHolder(IMessageSessionHolder session, Action <Exception> errorHandler) { _errorHandler = errorHandler; var transaction = session.IsTransactionEnabled; var marketData = session.IsMarketDataEnabled; if (marketData) { MarketDataAdapter = session.CreateMarketDataAdapter(); } if (transaction) { TransactionAdapter = session.CreateTransactionAdapter(); } var type = session.GetType(); var displayName = type.GetDisplayName(); if (!session.JoinInProcessors) { if (transaction) { ApplyMessageProcessor(displayName, MessageDirections.In, true, false); } if (marketData) { ApplyMessageProcessor(displayName, MessageDirections.In, false, true); } } else { ApplyMessageProcessor(displayName, MessageDirections.In, transaction, marketData); } if (!session.JoinOutProcessors) { if (transaction) { ApplyMessageProcessor(displayName, MessageDirections.Out, true, false); } if (marketData) { ApplyMessageProcessor(displayName, MessageDirections.Out, false, true); } } else { ApplyMessageProcessor(displayName, MessageDirections.Out, transaction, marketData); } }
private void Test_Click(object sender, RoutedEventArgs e) { if (!CheckIsValid()) { return; } BusyIndicator.IsBusy = true; Test.IsEnabled = false; var connector = new Connector { MarketDataAdapter = _editableSession.IsMarketDataEnabled ? _editableSession.CreateMarketDataAdapter() : new PassThroughMessageAdapter(_editableSession), TransactionAdapter = _editableSession.IsTransactionEnabled ? _editableSession.CreateTransactionAdapter() : new PassThroughMessageAdapter(_editableSession) }; connector.ApplyMessageProcessor(MessageDirections.In, true, true); connector.ApplyMessageProcessor(MessageDirections.Out, true, true); connector.ExportStarted += () => { connector.Dispose(); GuiDispatcher.GlobalDispatcher.AddSyncAction(() => { new MessageBoxBuilder() .Text(LocalizedStrings.Str1560) .Owner(this) .Show(); BusyIndicator.IsBusy = false; Test.IsEnabled = true; }); }; connector.Connected += connector.StartExport; Action <Exception> errorHandler = error => { connector.Dispose(); GuiDispatcher.GlobalDispatcher.AddSyncAction(() => { new MessageBoxBuilder() .Text(LocalizedStrings.Str1561 + Environment.NewLine + error) .Error() .Owner(this) .Show(); BusyIndicator.IsBusy = false; Test.IsEnabled = true; }); }; connector.ConnectionError += errorHandler; connector.ExportError += errorHandler; connector.Connect(); }