/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.SourceRole__EventChannelSourceRole == null)) { ISourceRole sourceRole__EventChannelSourceRoleCasted = item.As <ISourceRole>(); if ((sourceRole__EventChannelSourceRoleCasted != null)) { this._parent.SourceRole__EventChannelSourceRole = sourceRole__EventChannelSourceRoleCasted; return; } } if ((this._parent.AssemblyContext__EventChannelSourceConnector == null)) { IAssemblyContext assemblyContext__EventChannelSourceConnectorCasted = item.As <IAssemblyContext>(); if ((assemblyContext__EventChannelSourceConnectorCasted != null)) { this._parent.AssemblyContext__EventChannelSourceConnector = assemblyContext__EventChannelSourceConnectorCasted; return; } } if ((this._parent.EventChannel__EventChannelSourceConnector == null)) { IEventChannel eventChannel__EventChannelSourceConnectorCasted = item.As <IEventChannel>(); if ((eventChannel__EventChannelSourceConnectorCasted != null)) { this._parent.EventChannel__EventChannelSourceConnector = eventChannel__EventChannelSourceConnectorCasted; return; } } }
public LightweightExternalOrderbookService( IEventChannel <BestPriceChangeEventArgs> bestPriceChangeEventChannel, IOrderBookProviderApi orderBookProviderApi, IDateService dateService, IConvertService convertService, IScheduleSettingsCacheService scheduleSettingsCache, IAssetPairDayOffService assetPairDayOffService, IAssetPairsCache assetPairsCache, ICqrsSender cqrsSender, IIdentityGenerator identityGenerator, ILog log, MarginTradingSettings marginTradingSettings) { _bestPriceChangeEventChannel = bestPriceChangeEventChannel; _orderBookProviderApi = orderBookProviderApi; _dateService = dateService; _convertService = convertService; _scheduleSettingsCache = scheduleSettingsCache; _assetPairDayOffService = assetPairDayOffService; _assetPairsCache = assetPairsCache; _cqrsSender = cqrsSender; _identityGenerator = identityGenerator; _log = log; _defaultExternalExchangeId = string.IsNullOrEmpty(marginTradingSettings.DefaultExternalExchangeId) ? "Default" : marginTradingSettings.DefaultExternalExchangeId; _orderbookValidation = marginTradingSettings.OrderbookValidation; }
public void SetUp() { RegisterDependencies(); _quoteCacheService = Container.Resolve <IQuoteCacheService>(); _bestPriceConsumer = Container.Resolve <IEventChannel <BestPriceChangeEventArgs> >(); _cfdCalculatorService = Container.Resolve <ICfdCalculatorService>(); }
public LiquidationCommandsHandler( IAccountsCacheService accountsCache, IDateService dateService, IOperationExecutionInfoRepository operationExecutionInfoRepository, IChaosKitty chaosKitty, ITradingEngine tradingEngine, OrdersCache ordersCache, ILog log, IAccountUpdateService accountUpdateService, IEventChannel <LiquidationEndEventArgs> liquidationEndEventChannel, LiquidationHelper liquidationHelper, ILiquidationFailureExecutor failureExecutor) { _accountsCache = accountsCache; _dateService = dateService; _operationExecutionInfoRepository = operationExecutionInfoRepository; _chaosKitty = chaosKitty; _tradingEngine = tradingEngine; _ordersCache = ordersCache; _log = log; _accountUpdateService = accountUpdateService; _liquidationEndEventChannel = liquidationEndEventChannel; _liquidationHelper = liquidationHelper; _failureExecutor = failureExecutor; }
public ExternalOrderbookService( IEventChannel <BestPriceChangeEventArgs> bestPriceChangeEventChannel, IOrderBookProviderApi orderBookProviderApi, IDateService dateService, IConvertService convertService, IAssetPairDayOffService assetPairDayOffService, IScheduleSettingsCacheService scheduleSettingsCache, IAssetPairsCache assetPairsCache, ICqrsSender cqrsSender, IIdentityGenerator identityGenerator, ILog log, MarginTradingSettings marginTradingSettings) { _bestPriceChangeEventChannel = bestPriceChangeEventChannel; _orderBookProviderApi = orderBookProviderApi; _dateService = dateService; _convertService = convertService; _assetPairDayOffService = assetPairDayOffService; _scheduleSettingsCache = scheduleSettingsCache; _assetPairsCache = assetPairsCache; _cqrsSender = cqrsSender; _identityGenerator = identityGenerator; _log = log; _marginTradingSettings = marginTradingSettings; }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(IModelElement item) { IAssemblyContext assemblyContextItem = item.As <IAssemblyContext>(); if (((assemblyContextItem != null) && this._parent.AssemblyContexts__ComposedStructure.Remove(assemblyContextItem))) { return(true); } IResourceRequiredDelegationConnector resourceRequiredDelegationConnectorItem = item.As <IResourceRequiredDelegationConnector>(); if (((resourceRequiredDelegationConnectorItem != null) && this._parent.ResourceRequiredDelegationConnectors_ComposedStructure.Remove(resourceRequiredDelegationConnectorItem))) { return(true); } IEventChannel eventChannelItem = item.As <IEventChannel>(); if (((eventChannelItem != null) && this._parent.EventChannel__ComposedStructure.Remove(eventChannelItem))) { return(true); } IConnector connectorItem = item.As <IConnector>(); if (((connectorItem != null) && this._parent.Connectors__ComposedStructure.Remove(connectorItem))) { return(true); } return(false); }
public void SetUp() { RegisterDependencies(); _bestPriceConsumer = Container.Resolve <IEventChannel <BestPriceChangeEventArgs> >(); _accountsCacheService = Container.Resolve <IAccountsCacheService>(); _ordersCache = Container.Resolve <OrdersCache>(); }
public void Setup() { RegisterDependencies(); _validateOrderService = Container.Resolve <IValidateOrderService>(); _bestPriceConsumer = Container.Resolve <IEventChannel <BestPriceChangeEventArgs> >(); _ordersCache = Container.Resolve <OrdersCache>(); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IAssemblyContext assemblyContexts__ComposedStructureCasted = item.As <IAssemblyContext>(); if ((assemblyContexts__ComposedStructureCasted != null)) { this._parent.AssemblyContexts__ComposedStructure.Add(assemblyContexts__ComposedStructureCasted); } IResourceRequiredDelegationConnector resourceRequiredDelegationConnectors_ComposedStructureCasted = item.As <IResourceRequiredDelegationConnector>(); if ((resourceRequiredDelegationConnectors_ComposedStructureCasted != null)) { this._parent.ResourceRequiredDelegationConnectors_ComposedStructure.Add(resourceRequiredDelegationConnectors_ComposedStructureCasted); } IEventChannel eventChannel__ComposedStructureCasted = item.As <IEventChannel>(); if ((eventChannel__ComposedStructureCasted != null)) { this._parent.EventChannel__ComposedStructure.Add(eventChannel__ComposedStructureCasted); } IConnector connectors__ComposedStructureCasted = item.As <IConnector>(); if ((connectors__ComposedStructureCasted != null)) { this._parent.Connectors__ComposedStructure.Add(connectors__ComposedStructureCasted); } }
public ExternalOrderBooksList(IEventChannel <BestPriceChangeEventArgs> bestPriceChangeEventChannel, IDateService dateService, ILog log) { _bestPriceChangeEventChannel = bestPriceChangeEventChannel; _dateService = dateService; _log = log; }
public PositionsConsumer(OrdersCache ordersCache, IRabbitMqNotifyService rabbitMqNotifyService, IConvertService convertService, IDateService dateService, IAccountsCacheService accountsCacheService, IAccountUpdateService accountUpdateService, IIdentityGenerator identityGenerator, ICqrsSender cqrsSender, IEventChannel <OrderCancelledEventArgs> orderCancelledEventChannel, IEventChannel <OrderChangedEventArgs> orderChangedEventChannel, IEventChannel <OrderActivatedEventArgs> orderActivatedEventChannel, IMatchingEngineRouter meRouter, ILog log) { _ordersCache = ordersCache; _rabbitMqNotifyService = rabbitMqNotifyService; _convertService = convertService; _dateService = dateService; _accountsCacheService = accountsCacheService; _accountUpdateService = accountUpdateService; _identityGenerator = identityGenerator; _cqrsSender = cqrsSender; _orderCancelledEventChannel = orderCancelledEventChannel; _orderChangedEventChannel = orderChangedEventChannel; _orderActivatedEventChannel = orderActivatedEventChannel; _meRouter = meRouter; _log = log; }
/// <summary> /// Prevents a default instance of the ApplicationEndpoint class from being created /// </summary> public ApplicationEndpoint(IClientPlatform platform, ApplicationEndpointSettings applicationEndpointSettings, IEventChannel eventChannel) { ClientPlatform = platform; m_endpointSettings = applicationEndpointSettings; if (eventChannel != null) { m_eventChannel = eventChannel; m_eventChannel.HandleIncomingEvents += this.OnReceivedCallback; } Logger.Instance.Information("Initializing ApplicationEndpoint"); var oauthTokenIdentitifier = new OAuthTokenIdentifier( Constants.PlatformAudienceUri, applicationEndpointSettings.ApplicationEndpointId.Domain); var tokenProvider = new AADServiceTokenProvider(platform.AADClientId.ToString(), Constants.AAD_AuthorityUri, platform.AADAppCertificate, platform.AADClientSecret); if (!platform.IsInternalPartner) { TokenMapper.RegisterNameSpaceHandling(Constants.DefaultResourceNamespace, Constants.PublicServiceResourceNamespace); } TokenMapper.RegisterTypesInAssembly(Assembly.GetAssembly(typeof(ApplicationsResource))); m_tokenProvider = tokenProvider; m_oauthTokenIdentifier = oauthTokenIdentitifier; m_restfulClient = ((ClientPlatform)ClientPlatform).RestfulClientFactory.GetRestfulClient(m_oauthTokenIdentifier, m_tokenProvider); Logger.Instance.Information("ApplicationEndpoint Initialized!"); }
public LiquidationCommandsHandler( ITradingInstrumentsCacheService tradingInstrumentsCacheService, IAccountsCacheService accountsCache, IDateService dateService, IOperationExecutionInfoRepository operationExecutionInfoRepository, IChaosKitty chaosKitty, IMatchingEngineRouter matchingEngineRouter, ITradingEngine tradingEngine, OrdersCache ordersCache, ILog log, IAccountUpdateService accountUpdateService, IEventChannel <LiquidationEndEventArgs> liquidationEndEventChannel) { _tradingInstrumentsCacheService = tradingInstrumentsCacheService; _accountsCache = accountsCache; _dateService = dateService; _operationExecutionInfoRepository = operationExecutionInfoRepository; _chaosKitty = chaosKitty; _matchingEngineRouter = matchingEngineRouter; _tradingEngine = tradingEngine; _ordersCache = ordersCache; _log = log; _accountUpdateService = accountUpdateService; _liquidationEndEventChannel = liquidationEndEventChannel; }
public TcpServerProxyPublisher(TcpClient client, IEventChannel <TResource> channel) { _client = client; _channel = channel; var endpoint = (IPEndPoint)_client.Client.RemoteEndPoint; _clientAddress = new Address(endpoint.Address.ToString(), endpoint.Port); new Thread(() => { while (true) { while (_client.Available == 0) { ; } var stream = _client.GetStream(); var data = Helpers.ReadFromStream(stream); var message = Helpers.FromByteArray <Message>(data); if (message == Message.Unsubscribe) { _channel.UnregisterPublisher(_clientAddress); } } }).Start(); }
public AccountManager(AccountsCacheService accountsCacheService, IMarginTradingAccountsRepository repository, IConsole console, MarginSettings marginSettings, IRabbitMqNotifyService rabbitMqNotifyService, IAccountGroupCacheService accountGroupCacheService, IClientNotifyService clientNotifyService, IClientAccountClient clientAccountClient, IMarginTradingAccountsRepository accountsRepository, ITradingConditionsCacheService tradingConditionsCacheService, ILog log, OrdersCache ordersCache, IEventChannel <AccountBalanceChangedEventArgs> acountBalanceChangedEventChannel, ITradingEngine tradingEngine) : base(nameof(AccountManager), 60000, log) { _accountsCacheService = accountsCacheService; _clientAccountClient = clientAccountClient; _repository = repository; _console = console; _marginSettings = marginSettings; _rabbitMqNotifyService = rabbitMqNotifyService; _accountGroupCacheService = accountGroupCacheService; _accountsRepository = accountsRepository; _tradingConditionsCacheService = tradingConditionsCacheService; _log = log; _clientNotifyService = clientNotifyService; _ordersCache = ordersCache; _acountBalanceChangedEventChannel = acountBalanceChangedEventChannel; _tradingEngine = tradingEngine; }
// ------------ Triggers ------------ public void AddTriggerChannel(IEventChannel trigger) { if (EventChannels.Contains(trigger)) return; EventChannels.Add(trigger); }
public async Task RunAsync(Uri callbackUri) { m_logger = new SampleAppLogger(); // Uncomment for debugging // m_logger.HttpRequestResponseNeedsToBeLogged = true; // Prepare platform var platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, new Guid(QuickSamplesConfig.AAD_ClientId)); var platform = new ClientPlatform(platformSettings, m_logger); // You can hook up your own implementation of IEventChannel here IEventChannel eventChannel = WebEventChannel.WebEventChannel.Instance; // Prepare endpoint var endpointSettings = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId)); var applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel); var loggingContext = new LoggingContext(Guid.NewGuid()); await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); // Meeting configuration var meetingConfiguration = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + " test meeting"); // Schedule meeting var adhocMeeting = await applicationEndpoint.Application.CreateAdhocMeetingAsync(meetingConfiguration, loggingContext).ConfigureAwait(false); WriteToConsoleInColor("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri); WriteToConsoleInColor("ad hoc meeting join url : " + adhocMeeting.JoinUrl); // Get all the events related to join meeting through our custom callback uri platformSettings.SetCustomizedCallbackurl(callbackUri); // Start joining the meeting ICommunication communication = applicationEndpoint.Application.Communication; if (!communication.CanJoinAdhocMeeting(adhocMeeting)) { throw new Exception("Cannot join adhoc meeting"); } var invitation = await communication.JoinAdhocMeetingAsync(adhocMeeting, null, loggingContext).ConfigureAwait(false); // Wait for the join to complete await invitation.WaitForInviteCompleteAsync().ConfigureAwait(false); invitation.RelatedConversation.HandleParticipantChange += Conversation_HandleParticipantChange; WriteToConsoleInColor("Showing roaster udpates for 5 minutes for meeting : " + adhocMeeting.JoinUrl); // Wait 5 minutes before exiting. // Since we have registered Conversation_HandleParticipantChange, we will continue to show participant changes in the // meeting for this duration. await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false); await WebEventChannel.WebEventChannel.Instance.TryStopAsync().ConfigureAwait(false); }
public void SetUp() { RegisterDependencies(); _accountAssetsManager = Container.Resolve <TradingInstrumentsManager>(); _swapService = Container.Resolve <ICommissionService>(); _tradingInstruments = Container.Resolve <ITradingInstrumentsApi>(); _bestPriceConsumer = Container.Resolve <IEventChannel <BestPriceChangeEventArgs> >(); }
// ------------ Triggers ------------ public void AddTriggerChannel(IEventChannel trigger) { if (EventChannels.Contains(trigger)) { return; } EventChannels.Add(trigger); }
public Event(IEventChannel owner, string name) { Owner = owner; Name = name; Actions = new List <Action <object> >(); SignalChannelObjects = new Dictionary <Action <object>, ISignalChannel>(); OrderByDelegate = Brain.KB.Sources.GetSignalChannelIndex; }
public void Setup() { RegisterDependencies(); _validateOrderService = Container.Resolve <IValidateOrderService>(); _bestPriceConsumer = Container.Resolve <IEventChannel <BestPriceChangeEventArgs> >(); _ordersCache = Container.Resolve <OrdersCache>(); _assetPairsCache = Container.Resolve <IAssetPairsCache>(); _me = new FakeMatchingEngine(1); }
public void ConfigureLogger() { var formatter = new MessageTemplateTextFormatter("${date} [${threadid}] ${level} ${logger} ${ndc} - ${message}${newline}", null); var channelFactory = Substitute.For<ChannelFactory>(); _channel = Substitute.For<IEventChannel>(); channelFactory.Create("localhost", 8765, 1).Returns(_channel); _sink = new BrowserConsoleSink(true, 8765, 1, formatter,false, channelFactory); }
public void SetUp() { RegisterDependencies(); _accountAssetsManager = Container.Resolve <AccountAssetsManager>(); _swapService = Container.Resolve <ICommissionService>(); _accountAssetsRepository = Container.Resolve <IAccountAssetPairsRepository>(); _bestPriceConsumer = Container.Resolve <IEventChannel <BestPriceChangeEventArgs> >(); }
public Event(IEventChannel owner, string name) { Owner = owner; Name = name; Actions = new List<Action<object>>(); SignalChannelObjects = new Dictionary<Action<object>, ISignalChannel>(); OrderByDelegate = Brain.KB.Sources.GetSignalChannelIndex; }
/// <summary> /// /// </summary> /// /// <param name="name"></param> /// public MessageSenderEventStream(string name) { this.name = name; channel = new MessageSenderEventChannel(name); if (Logger.IsDebugEnabled) { Logger.Debug(string.Format("message sender event stream initialized for: {0}.", name)); } }
public void AddChannel(IEventChannel channel, CancellationToken token) { lock (_syncRoot) { _channels.Add(channel); foreach (var message in _replayBuffer) { channel.Send(message, token); } } }
public override void ActivateOptions() { if (Active) { if (Host == null) { Host = DefaultHostFinder.FindLocalIp(); } _channel = _channelFactory.Create(Host, Port, Buffer); } }
public void AddChannel(IEventChannel channel, CancellationToken token) { lock (_syncRoot) { _channels.Add(channel); foreach (var message in _replayBuffer) { channel.Send(message, token); } } }
public override void ActivateOptions() { if (Active) { if (Host == null) { Host = DefaultHostFinder.FindLocalIp(); } _channel = _channelFactory.Create(Host, Port, Buffer); } }
public MarketMakerMatchingEngine( string id, IEventChannel <BestPriceChangeEventArgs> bestPriceChangeEventChannel, OrderBookList orderBooks, IContextFactory contextFactory) { Id = id; _bestPriceChangeEventChannel = bestPriceChangeEventChannel; _orderBooks = orderBooks; _contextFactory = contextFactory; }
public async Task RunAsync(Uri callbackUri) { var targetUserId = ConfigurationManager.AppSettings["Skype_TargetUserId"]; m_logger = new SampleAppLogger(); // Uncomment for debugging // m_logger.HttpRequestResponseNeedsToBeLogged = true; // You can hook up your own implementation of IEventChannel here IEventChannel eventChannel = WebEventChannel.WebEventChannel.Instance; // Prepare platform var platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, new Guid(QuickSamplesConfig.AAD_ClientId)); var platform = new ClientPlatform(platformSettings, m_logger); // Prepare endpoint var endpointSettings = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId)); var applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel); var loggingContext = new LoggingContext(Guid.NewGuid()); await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); // Get all the events related to join meeting through our custom callback uri platformSettings.SetCustomizedCallbackurl(callbackUri); WriteToConsoleInColor("Start to send messaging invitation"); var invitation = await applicationEndpoint.Application.Communication.StartMessagingAsync( "Subject", new SipUri(targetUserId), null, loggingContext).ConfigureAwait(false); // Wait for user to accept the invitation var conversation = await invitation.WaitForInviteCompleteAsync().ConfigureAwait(false); conversation.HandleParticipantChange += Conversation_HandleParticipantChange; conversation.MessagingCall.IncomingMessageReceived += Handle_IncomingMessage; // Send the initial message await conversation.MessagingCall.SendMessageAsync("Hello World!", loggingContext).ConfigureAwait(false); WriteToConsoleInColor("Staying in the conversation for 5 minutes"); // Wait 5 minutes before exiting // Since we registered callbacks, we will continue to show message logs await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false); await WebEventChannel.WebEventChannel.Instance.TryStopAsync().ConfigureAwait(false); }
public OrderStateConsumer(IRabbitMqNotifyService rabbitMqNotifyService, OrdersCache ordersCache, IDateService dateService, IEventChannel <OrderCancelledEventArgs> orderCancelledEventChannel, IEventChannel <OrderChangedEventArgs> orderChangedEventChannel) { _rabbitMqNotifyService = rabbitMqNotifyService; _ordersCache = ordersCache; _dateService = dateService; _orderCancelledEventChannel = orderCancelledEventChannel; _orderChangedEventChannel = orderChangedEventChannel; }
private void CreateChannel(ChannelFactory channelFactory = null) { if (Active) { _channelFactory = channelFactory ?? new ChannelFactory(); if (Host == null) { Host = DefaultHostFinder.FindLocalIp(); } _channel = _channelFactory.Create(Host, Port, Buffer); } }
protected override void InitializeTarget() { base.InitializeTarget(); if (Active) { if (Host == null) { Host = DefaultHostFinder.FindLocalIp(); } _channel = _channelFactory.Create(Host, Port, Buffer); } }
protected override void InitializeTarget() { base.InitializeTarget(); if (Active) { if (Host == null) { Host = DefaultHostFinder.FindLocalIp(); } _channel = _channelFactory.Create(Host, Port, Buffer); } }
public FxRateCacheService(ILog log, IMarginTradingBlobRepository blobRepository, IEventChannel <FxBestPriceChangeEventArgs> fxBestPriceChangeEventChannel, MarginTradingSettings marginTradingSettings, IAssetPairDayOffService assetPairDayOffService) : base(nameof(FxRateCacheService), marginTradingSettings.BlobPersistence.FxRatesDumpPeriodMilliseconds, log) { _log = log; _blobRepository = blobRepository; _fxBestPriceChangeEventChannel = fxBestPriceChangeEventChannel; _assetPairDayOffService = assetPairDayOffService; _quotes = new Dictionary <string, InstrumentBidAskPair>(); }
public void ConfigureLogger() { var channelFactory = Substitute.For <ChannelFactory>(); _channel = Substitute.For <IEventChannel>(); channelFactory.Create("localhost", 3365, null, 1).Returns(_channel); _target = new ProxyTarget(channelFactory) { Active = false, Host = "localhost", Port = 3365, ReplayBufferSize = 1, }; }
public TradingEngine( IEventChannel <MarginCallEventArgs> marginCallEventChannel, IEventChannel <OrderPlacedEventArgs> orderPlacedEventChannel, IEventChannel <OrderExecutedEventArgs> orderClosedEventChannel, IEventChannel <OrderCancelledEventArgs> orderCancelledEventChannel, IEventChannel <OrderChangedEventArgs> orderChangedEventChannel, IEventChannel <OrderExecutionStartedEventArgs> orderExecutionStartedEventChannel, IEventChannel <OrderActivatedEventArgs> orderActivatedEventChannel, IEventChannel <OrderRejectedEventArgs> orderRejectedEventChannel, IValidateOrderService validateOrderService, IAccountsCacheService accountsCacheService, OrdersCache ordersCache, IMatchingEngineRouter meRouter, IThreadSwitcher threadSwitcher, IAssetPairDayOffService assetPairDayOffService, ILog log, IDateService dateService, ICfdCalculatorService cfdCalculatorService, IIdentityGenerator identityGenerator, IAssetPairsCache assetPairsCache, ICqrsSender cqrsSender, IEventChannel <StopOutEventArgs> stopOutEventChannel, IQuoteCacheService quoteCacheService, MarginTradingSettings marginTradingSettings) { _marginCallEventChannel = marginCallEventChannel; _orderPlacedEventChannel = orderPlacedEventChannel; _orderExecutedEventChannel = orderClosedEventChannel; _orderCancelledEventChannel = orderCancelledEventChannel; _orderActivatedEventChannel = orderActivatedEventChannel; _orderExecutionStartedEvenChannel = orderExecutionStartedEventChannel; _orderChangedEventChannel = orderChangedEventChannel; _orderRejectedEventChannel = orderRejectedEventChannel; _validateOrderService = validateOrderService; _accountsCacheService = accountsCacheService; _ordersCache = ordersCache; _meRouter = meRouter; _threadSwitcher = threadSwitcher; _assetPairDayOffService = assetPairDayOffService; _log = log; _dateService = dateService; _cfdCalculatorService = cfdCalculatorService; _identityGenerator = identityGenerator; _assetPairsCache = assetPairsCache; _cqrsSender = cqrsSender; _stopOutEventChannel = stopOutEventChannel; _quoteCacheService = quoteCacheService; _marginTradingSettings = marginTradingSettings; }
public void ConfigureLogger() { var layout = new SimpleLayout("${date} [${threadid}] ${level} ${logger} ${ndc} - ${message}${newline}"); var channelFactory = Substitute.For<ChannelFactory>(); _channel = Substitute.For<IEventChannel>(); channelFactory.Create("localhost", 8765, 1).Returns(_channel); _target = new BrowserConsoleTarget(channelFactory) { Host = "localhost", Port = 8765, Layout = layout, Buffer = 1, Name = "ConsoleTest" }; }
public void Should_have_no_side_effect_if_active_flag_set_to_false() { // given var channelFactory = Substitute.For<ChannelFactory>(); _channel = Substitute.For<IEventChannel>(); channelFactory.Create(Arg.Any<string>(), 8765, 1).Returns(_channel); var messageTemplateTextFormatter = Substitute.For<MessageTemplateTextFormatter>(BrowserConsoleLoggerConfigurationExtensions.DefaultOutputTemplate, null); var sink = new BrowserConsoleSink(false, 8765, 1, messageTemplateTextFormatter, false, channelFactory); var logEvent = new LogEvent(new DateTimeOffset(new DateTime(2010, 10, 12)), LogEventLevel.Information, new Exception("test"), GenerateMessageTemplate("Useless text"), new List<LogEventProperty>()); // when sink.Emit(logEvent); // then messageTemplateTextFormatter.DidNotReceiveWithAnyArgs().Format(logEvent, new StringWriter()); }
public void ConfigureLogger() { var layout = new PatternLayout("%-4timestamp [%thread] %-5level %logger %ndc - %message%newline"); var channelFactory = Substitute.For<ChannelFactory>(); _channel = Substitute.For<IEventChannel>(); channelFactory.Create("localhost", 8765, 1).Returns(_channel); _appender = new BrowserConsoleAppender(channelFactory) { Host = "localhost", Port = 8765, Layout = layout, Buffer = 1 }; layout.ActivateOptions(); }
public void Should_send_an_sse_message_when_receiving_a_logging_event() { // given var channelFactory = Substitute.For<ChannelFactory>(); _channel = Substitute.For<IEventChannel>(); channelFactory.Create(Arg.Any<string>(), 8765, 1).Returns(_channel); var messageTemplateTextFormatter = new MessageTemplateTextFormatter(BrowserConsoleLoggerConfigurationExtensions.DefaultOutputTemplate, null); var sink = new BrowserConsoleSink(true, 8765, 1, messageTemplateTextFormatter, false, channelFactory); var logEvent = new LogEvent( new DateTimeOffset(new DateTime(2010, 10, 12)), LogEventLevel.Information, null, GenerateMessageTemplate("Everything's fine with Serilog"), new List<LogEventProperty>() { new LogEventProperty("test", new ScalarValue("value"))}); // when sink.Emit(logEvent); // then _channel.Received().Send(Arg.Is<ServerSentEvent>(evt => evt.ToString().Contains("Everything's fine with Serilog")), Arg.Any<CancellationToken>()); }
public void Should_send_a_multiline_sse_message_received_logging_event_for_an_exception() { // given var channelFactory = Substitute.For<ChannelFactory>(); _channel = Substitute.For<IEventChannel>(); channelFactory.Create(Arg.Any<string>(), 8765, 1).Returns(_channel); var messageTemplateTextFormatter = new MessageTemplateTextFormatter(BrowserConsoleLoggerConfigurationExtensions.DefaultOutputTemplate, null); var sink = new BrowserConsoleSink(true, 8765, 1, messageTemplateTextFormatter, false, channelFactory); var logEvent = new LogEvent( new DateTimeOffset(new DateTime(2010, 10, 12)), LogEventLevel.Fatal, new Exception("Message of the exception"), GenerateMessageTemplate("Displaying of an exception"), new List<LogEventProperty>() { new LogEventProperty("test", new ScalarValue("value")) }); // when sink.Emit(logEvent); // then var lineSeparator = new string[] { "\r\n" }; _channel.Received().Send( Arg.Is<ServerSentEvent>( evt => evt.ToString() .Split(lineSeparator, StringSplitOptions.RemoveEmptyEntries) .Skip(1) .All(l => l.StartsWith("data:")) ), Arg.Any<CancellationToken>()); }
public void Should_dispose_channel_on_shutdown() { // given var channelFactory = Substitute.For<ChannelFactory>(); _channel = Substitute.For<IEventChannel>(); channelFactory.Create(Arg.Any<string>(), 8765, 1).Returns(_channel); var sink = new BrowserConsoleSink(true, 8765, 1, null, false, channelFactory); //When sink.Dispose(); // then _channel.Received().Dispose(); }