Beispiel #1
0
 public ResetPasswordService(IUserService userService, IPasswordManagementService passwordManagementService,
     IMessageParser<ResetPasswordMessageTemplate, User> messageParser)
 {
     _userService = userService;
     _passwordManagementService = passwordManagementService;
     _messageParser = messageParser;
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqsQueue" /> class.
        /// </summary>
        /// <param name="endpoint">Region the queue is in</param>
        /// <param name="queueName">Name of the queue</param>
        /// <param name="retryCount">Number of times to retry a message before moving it to the dead letter queue</param>
        /// <param name="messageParser">Message parser</param>
        public SqsQueue(RegionEndpoint endpoint, string queueName, int retryCount, IMessageParser messageParser)
        {
            _simpleQueueService        = new AmazonSQSClient(endpoint);
            _simpleNotificationService = new Lazy <IAmazonSimpleNotificationService>(() => new AmazonSimpleNotificationServiceClient(endpoint));
            CreateQueueResponse createResponse = _simpleQueueService.CreateQueue(queueName);

            _queueUrl = createResponse.QueueUrl;
            var attributes = _simpleQueueService.GetAttributes(_queueUrl);

            _queueArn = attributes["QueueArn"];
            if (!attributes.ContainsKey("RedrivePolicy"))
            {
                createResponse = _simpleQueueService.CreateQueue(queueName + "_Dead_Letter");
                string deadLetterQueue      = createResponse.QueueUrl;
                var    deadLetterAttributes = _simpleQueueService.GetAttributes(deadLetterQueue);
                string redrivePolicy        = string.Format(CultureInfo.InvariantCulture, "{{\"maxReceiveCount\":\"{0}\", \"deadLetterTargetArn\":\"{1}\" }}", retryCount, deadLetterAttributes["QueueArn"]);
                _simpleQueueService.SetQueueAttributes(_queueUrl, new Dictionary <string, string>()
                {
                    { "RedrivePolicy", redrivePolicy }, { "MessageRetentionPeriod", "1209600" }
                });
                _simpleQueueService.SetQueueAttributes(createResponse.QueueUrl, new Dictionary <string, string>()
                {
                    { "MessageRetentionPeriod", "1209600" }
                });
            }

            MessageParser       = messageParser;
            MaxNumberOfMessages = 10;
        }
Beispiel #3
0
 // private constructor
 public UdpMessageClient(string host, int port, int localPort, IMessageParser parser)
 {
     _host      = host;
     _port      = port;
     _localPort = localPort;
     _parser    = parser;
 }
 public ConversationChooser(IConversationsRepository respository, IMessageParser messageParser, IConversationUsersRepository conversationUsersRepository, IConsole console)
 {
     this.respository   = respository;
     this.messageParser = messageParser;
     this.conversationUsersRepository = conversationUsersRepository;
     this.console = console;
 }
 public ResetPasswordService(IUserService userService, IPasswordManagementService passwordManagementService,
                             IMessageParser <ResetPasswordMessageTemplate, User> messageParser)
 {
     _userService = userService;
     _passwordManagementService = passwordManagementService;
     _messageParser             = messageParser;
 }
Beispiel #6
0
        public void StartListener(IMessageStorage storage, IMessageParser parser)
        {
            bool       done     = false;
            UdpClient  listener = new UdpClient(_port);
            IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, _port);

            try
            {
                while (!done)
                {
                    byte[] bytes = listener.Receive(ref endPoint);
                    if (bytes.Length > MaxMessageLength)
                    {
                        continue;
                    }

                    var rawmessage = Encoding.ASCII.GetString(bytes, 0, bytes.Length);
                    storage.Add(parser.Parse(rawmessage, endPoint.Address));
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                listener.Close();
            }
        }
Beispiel #7
0
 public BotController(IMessageParser messageParser, IConfiguration configuration, ITelegramRepository telegramRepository)
 {
     //Injected dependencies
     _messageParser      = messageParser;
     _telegramRepository = telegramRepository;
     _token = configuration["BlimpBotTelegramToken"];
 }
Beispiel #8
0
        /// <summary>
        ///     Initializes a new instance of the MessageReceiver class.
        /// </summary>
        /// <param name="messageParser">Message parser.</param>
        /// <param name="blacklist">IP addresses that should be ignore when receiving messages.</param>
        public MessageReceiver(IMessageParser messageParser, List <IPAddress> blacklist)
        {
            _messageParser = messageParser;
            Blacklist      = blacklist;

            _client = new UdpClient(Port);
        }
Beispiel #9
0
        public void StartListener(IMessageStorage storage, IMessageParser parser)
        {
            bool done = false;
            UdpClient listener = new UdpClient(_port);
            IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, _port);

            try
            {
                while (!done)
                {
                    byte[] bytes = listener.Receive(ref endPoint);
                    if (bytes.Length > MaxMessageLength)
                        continue;

                    var rawmessage = Encoding.ASCII.GetString(bytes, 0, bytes.Length);
                    storage.Add(parser.Parse(rawmessage, endPoint.Address));
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                listener.Close();
            }
        }
 public DeviceLocator(ISocketFactory socketFactory, IRequestFactory requestFactory, IMessageParser messageParser, IDeviceInfoCollector deviceInfoCollector)
 {
     _socketFactory = socketFactory;
     _requestFactory = requestFactory;
     _messageParser = messageParser;
     _deviceInfoCollector = deviceInfoCollector;
 }
Beispiel #11
0
 public ServiceMessageBus(IDependencyResolver resolver) : base(resolver)
 {
     // TODO: find a more decent way instead of DI, it can be easily overriden
     _serviceConnectionManager = resolver.Resolve <IServiceConnectionManager>() ?? throw new ArgumentNullException(nameof(IServiceConnectionManager));
     _parser     = resolver.Resolve <IMessageParser>() ?? throw new ArgumentNullException(nameof(IMessageParser));
     _ackHandler = resolver.Resolve <IAckHandler>() ?? throw new ArgumentNullException(nameof(IAckHandler));
 }
Beispiel #12
0
 // private constructor
 public TcpMessageClient(string host, int port, bool needHB, IMessageParser parser)
 {
     _host   = host;
     _port   = port;
     _needHB = needHB;
     _parser = parser;
 }
        public void When_parser_matcher_finds_match_it_should_return_a_message_parser()
        {
            // Act
            IMessageParser actual = _sut.GetParser("message-data");

            // Assert
            actual.Should().Be(_dummyParserMock.Object);
        }
Beispiel #14
0
 public void OnMessage(IMessageParser parser)
 {
     OnTopicMessage msg = MessageEvent;
     if (msg != null)
     {
         msg(parser);
     }
 }
Beispiel #15
0
 void Initialise()
 {
     _buffer         = new byte[8192];
     _recvBuf        = new StringBuilder();
     _recvBufWaiting = false;
     _recvTickCount  = 0;
     _parser         = new DefaultMessageParser();
 }
 public IncomingMessageProcessor(IMessageRepository messageRepository, ITagRepository tagRepository, IMessageParser messageParser, IValidMessageReceiver validMessageReceiver, IAllMessageReceiver allMessageReceiver)
 {
     _messageRepository = messageRepository;
     _messageParser = messageParser;
     _tagRepository = tagRepository;
     _validMessageReceiver = validMessageReceiver;
     _allMessageReceiver = allMessageReceiver;
 }
Beispiel #17
0
        /// <summary>
        /// Event rises on server accept client.
        /// </summary>
        /// <param name="sender">Object that send the event.</param>
        /// <param name="networkClient">Client connected.</param>
        private void AcceptNetworkClient(object sender, ClientAcceptedEventArgs e)
        {
            IMessageParser        messageParser     = this.Binding.CreateParser();
            IMessageSerializer    messageSerializer = this.Binding.MessageSerializer;
            Channel <TController> channel           = new Channel <TController>(e.NetworkClient, messageParser, messageSerializer);

            this.ChannelList.Add(channel);
        }
 public ResetPasswordService(IUserManagementService userManagementService, IPasswordManagementService passwordManagementService,
                             IMessageParser <ResetPasswordMessageTemplate, User> messageParser, IUserLookup userLookup)
 {
     _userManagementService     = userManagementService;
     _passwordManagementService = passwordManagementService;
     _messageParser             = messageParser;
     _userLookup = userLookup;
 }
 public IrcClient(IMessageParser parser, IResponseValidator responseValidator, ISocket socket, bool isConnected, bool connecting)
 {
     this.parser = parser;
     this.responseValidator = responseValidator;
     this.socket = socket;
     IsConnected = isConnected;
     this.connecting = connecting;
 }
        public void Setup()
        {
            var propertyMapper = new TagToPropertyMapper(new SubPropertySetterFactory());

            propertyMapper.Map <TestTypeParent>();

            _parser = new TypedStringMessageParser <TestTypeParent>(propertyMapper, new CompositePropertySetter(), new ValidatorCollection(IntegerToFixConverter.Instance), new RapideFix.Business.Data.MessageParserOptions());
        }
        public SocketServer()
        {
            _messageParser = new MessageParser();

            _rooms = new RoomsPool();
            _rooms.OnRoomCreated        += FireRoomCreated;
            _rooms.OnRoomDestroyed      += FireRoomDestroyed;
            _rooms.OnClientDisconnected += FireClientDisconnected;
        }
 public DiscoveryListener(ISocketFactory socketFactory, IResponseFactory responseFactory, IMessageParser messageParser, IDeviceInfoCollector deviceInfoCollector)
 {
     _socketFactory = socketFactory;
     _responseFactory = responseFactory;
     _messageParser = messageParser;
     _deviceInfoCollector = deviceInfoCollector;
     _stopped = true;
     _started = false;
 }
Beispiel #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Channel{TController}"/> class.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="networkClient">The e.</param>
 public Channel(INetworkClient networkClient, IMessageParser messageParser, IMessageSerializer messageSerializer, ChannelControllerFactory <TChannelController> channelControllerFactory = null)
 {
     this.ChannelControllerFactory = channelControllerFactory ?? new ChannelControllerFactory <TChannelController>();
     this.InitializeNetworkClient(networkClient);
     this.InitializeSerializer(messageSerializer);
     this.InitializeNotifier();
     this.InitializeParser(messageParser);
     this.InitializeController();
 }
Beispiel #24
0
        public void Setup()
        {
            _message = new TestFixMessageBuilder("35=A|101=345|102=128.79|").Build();
            var propertyMapper = new TagToPropertyMapper(new SubPropertySetterFactory());

            propertyMapper.Map <TestTypeStruct>();

            _parser = new TypedMessageParser <TestTypeStruct>(propertyMapper, new CompositePropertySetter(), new ValidatorCollection(IntegerToFixConverter.Instance), new RapideFix.Business.Data.MessageParserOptions());
        }
        public ChatServer(IMessageParser messageParser, IMessageHandlerFactory messageHandlerFactory)
        {
            _messageParser = messageParser;
            _messageHandlerFactory = messageHandlerFactory;

            _socket = new DumbSocket();
            _socket.Start();
            _socket.IncomingMessage += OnSocketIncomingMessage;
        }
Beispiel #26
0
        // ReSharper restore RedundantArgumentDefaultValue

        public MessageRouter(
            IMessageParser messageParser = null,
            ITypeLocator typeLocator     = null,
            IResolver resolver           = null)
        {
            _messageParser = messageParser ?? DefaultMessageParser.Current;
            _typeLocator   = typeLocator ?? DefaultTypeLocator.Current;
            _resolver      = resolver ?? new AutoContainer();
        }
Beispiel #27
0
 public ResetPasswordServiceTests()
 {
     _userService = A.Fake <IUserService>();
     _passwordManagementService = A.Fake <IPasswordManagementService>();
     _messageParser             = A.Fake <IMessageParser <ResetPasswordMessageTemplate, User> >();
     _resetPasswordService      = new ResetPasswordService(_userService,
                                                           _passwordManagementService,
                                                           _messageParser);
 }
Beispiel #28
0
        public void OnMessage(IMessageParser parser)
        {
            OnTopicMessage msg = MessageEvent;

            if (msg != null)
            {
                msg(parser);
            }
        }
Beispiel #29
0
        public void TestRefreshConfiguration()
        {
            IMessageParser parser1 = MessageParserManager.GetParser("XmlMessageParser");

            MessageParserManager.RefreshConfiguration("XmlMessageParser");
            IMessageParser parser2 = MessageParserManager.GetParser("XmlMessageParser");

            Assert.IsFalse(object.ReferenceEquals(parser1, parser2), "Incorrect RefreshConfiguration implementation.");
        }
 public ResetPasswordServiceTests()
 {
     _userService = A.Fake<IUserService>();
     _passwordManagementService = A.Fake<IPasswordManagementService>();
     _messageParser = A.Fake<IMessageParser<ResetPasswordMessageTemplate, User>>();
     _resetPasswordService = new ResetPasswordService(_userService,
                                                      _passwordManagementService,
                                                      _messageParser);
 }
 /// <summary>
 /// Creates an object responsible for receiving messages and handling them.
 /// It is able to detect that some messages were potentially lost.
 /// </summary>
 /// <param name="connectionMultiplexer">A multiplexer providing low-level communication with Redis server</param>
 /// <param name="messageParser">an object responsible for analyzing a raw string message and parsing it to a structured <see cref="Message"/></param>
 /// <param name="loggerFactory">logger factory for creating loggers to trace internal activity of this subscriber</param>
 public ReliableSubscriber(
     IConnectionMultiplexer connectionMultiplexer,
     IMessageParser messageParser,
     ILoggerFactory loggerFactory = null)
 {
     _connectionMultiplexer = connectionMultiplexer;
     _messageParser         = messageParser;
     _loggerFactory         = loggerFactory ?? NullLoggerFactory.Instance;
     _log = _loggerFactory.CreateLogger <ReliableSubscriber>();
 }
Beispiel #32
0
 public ImportExportManager(IImportDocumentsValidationService importDocumentsValidationService,
                            IImportDocumentsService importDocumentsService, IExportDocumentsService exportDocumentsService,
                            IMessageParser <ExportDocumentsEmailTemplate> messageParser, IRepository <Webpage> webpageRepository)
 {
     _importDocumentsValidationService = importDocumentsValidationService;
     _importDocumentService            = importDocumentsService;
     _exportDocumentsService           = exportDocumentsService;
     _messageParser     = messageParser;
     _webpageRepository = webpageRepository;
 }
 public KoalaChatHub(IMessageParser messageParser,
                     IMediator mediator,
                     IRepository <ChatUser> userRepository,
                     ILogger <KoalaChatHub> logger)
 {
     _messageParser  = messageParser;
     _mediator       = mediator;
     _userRepository = userRepository;
     _logger         = logger;
 }
Beispiel #34
0
 public ImportExportManager(IImportDocumentsValidationService importDocumentsValidationService,
                            IImportDocumentsService importDocumentsService, IExportDocumentsService exportDocumentsService,
                            IDocumentService documentService, IMessageParser <ExportDocumentsEmailTemplate> messageParser)
 {
     _importDocumentsValidationService = importDocumentsValidationService;
     _importDocumentService            = importDocumentsService;
     _exportDocumentsService           = exportDocumentsService;
     _documentService = documentService;
     _messageParser   = messageParser;
 }
Beispiel #35
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            CBWrapper wrapper = skillParser.SelectedItem as CBWrapper;

            if (wrapper != null && wrapper.Parser != null)
            {
                messageParser = wrapper.Parser;
                Start();
            }
        }
Beispiel #36
0
        public PipeParser(PipeReader pipeReader, IMessageParser <T, byte> singleMessageParser, SupportedFixVersion fixVersion, Func <ReadOnlyMemory <byte>, T>?targetObjectFactory)
        {
            _reader              = pipeReader ?? throw new ArgumentNullException(nameof(pipeReader));
            _messageParser       = singleMessageParser ?? throw new ArgumentNullException(nameof(singleMessageParser));
            _targetObjectFactory = targetObjectFactory;
            _fixVersion          = new byte[fixVersion.Value.Length + 2];
            int offset = Encoding.ASCII.GetBytes("8=".AsSpan(), _fixVersion);

            fixVersion.Value.CopyTo(_fixVersion.AsSpan().Slice(offset));
        }
Beispiel #37
0
        public ServerNetListener CreateNet(int serverID, IMessageParser messageParser, int port = 9999)
        {
            ServerNetListener serverNetListener = NetManager.GetInstance().GetServerNet(serverID);

            if (serverNetListener == null)
            {
                serverNetListener = NetManager.GetInstance().CreateServerNet(serverID, port, messageParser);
            }

            return(serverNetListener);
        }
Beispiel #38
0
 public InterProcessUpdateReceiver(IEnvironmentInformation environmentInformation, StreamFactory streamFactory, ILog log, ICommunicationProtocol externalProtocol, IMessageParser messageParser)
 {
     serverName = environmentInformation.InterProcessServerNameBase +
                  environmentInformation.CurrentProcessId.ToString("D", CultureInfo.InvariantCulture);
     this.streamFactory                = streamFactory;
     this.log                          = log;
     this.externalProtocol             = externalProtocol;
     this.messageParser                = messageParser;
     messageParser.HandshakeCompleted += MessageParserOnHandshakeCompleted;
     StartAndWaitForInterProcessUpdate();
 }
Beispiel #39
0
        public void Setup()
        {
            string sampleInput = SampleFixMessagesSource.GetTestTypeParentMessageBodies().First().First() as string;

            _message = new TestFixMessageBuilder(sampleInput).Build();
            var propertyMapper = new TagToPropertyMapper(new SubPropertySetterFactory());

            propertyMapper.Map <TestTypeParent>();

            _parser = new MessageParser(propertyMapper, new CompositePropertySetter(), new ValidatorCollection(IntegerToFixConverter.Instance), new RapideFix.Business.Data.MessageParserOptions());
        }
        public TcpReader(TcpClient tcpClient, IMessageParser messageParser, int bufferSize)
        {
            ParameterValidator.ParameterValidator.EnsureParametersAreValid(new NullValidatorWithValue<TcpClient>(() => tcpClient, tcpClient),
                                                                           new NullValidatorWithValue<IMessageParser>(() => messageParser, messageParser),
                                                                           new MinValueValidatorWithValue<int>(() => bufferSize, bufferSize, 1));
            _messageParser = messageParser;
            _bufferSize = bufferSize;
            if (tcpClient.Connected == false)
                throw new InvalidOperationException("The tcpClient is not connected.");

            _networkStream = tcpClient.GetStream();
        }
Beispiel #41
0
 private void OnTopicMessage(IMessageParser parser)
 {
     OnTopicMessage msg = TopicMessageEvent;
     if (msg != null)
     {
         string topic = parser.Topic;
         if (_regex.IsMatch(parser.Topic))
         {
             msg(parser);
         }
     }
 }
Beispiel #42
0
        static void Main(string[] args)
        {
            _parser = new FileContentParser();

            var files = new DirectoryInfo(@"c:\temp").GetFiles();

            foreach (var file in files)
            {
                string content = CleanUpContent(File.ReadAllText(file.FullName));

                var message = _parser.Parse(content);
                WriteMesaageFile(message, content);
            }
        }
Beispiel #43
0
 private void OnMessage(IMessageParser parser)
 {
     ByteMessageParser bytes = new ByteMessageParser(parser.Topic, parser.ParseBytes(), parser.EndPoint);
     bool discard = false;
     lock (_lock)
     {
         if (_msgQueue.Count >= _maxSize)
         {
             discard = true;
         }
         else
         {
             _msgQueue.Add(bytes);
             Monitor.Pulse(_lock);
         }
     }
     OnTopicMessage discardMsg = DiscardEvent;
     if (discard && discardMsg != null)
     {
         discardMsg(bytes);
     }
 }
Beispiel #44
0
 public void OnMessage(IMessageParser parser)
 {
     _msgCount++;
 }
 public SendOrderPlacedEmailToStoreOwner(ISession session,
     IMessageParser<SendOrderPlacedEmailToStoreOwnerMessageTemplate, Order> messageParser)
 {
     _session = session;
     _messageParser = messageParser;
 }
 public void BeforeEachTest()
 {
     _parser = new FileContentParser();
 }
 public void BeforeEachTest()
 {
     _parser = new FileNameParser();
 }
 public MessageRepository(IMessageParser parser, string messageDirectory)
 {
     _parser = parser;
     _messageDirectory = messageDirectory;
     _directory = new DirectoryInfo(_messageDirectory);
 }
 public SendOrderCancelledEmailToCustomer(ISession session, 
     IMessageParser<SendOrderCancelledEmailToCustomerMessageTemplate, Order> messageParser)
 {
     _session = session;
     _messageParser = messageParser;
 }
 public ResponseFactory(DeviceInformation deviceInformation, IMessageParser messageParser)
 {
     _deviceInformation = deviceInformation;
     _messageParser = messageParser;
 }
 public static void SetCurrent(IMessageParser messageParser)
 {
     _messageParser.Value = messageParser;
 }
Beispiel #52
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     CBWrapper wrapper = skillParser.SelectedItem as CBWrapper;
     if (wrapper != null && wrapper.Parser != null)
     {
         messageParser = wrapper.Parser;
         Start();
     }
 }
 public QueueCommentReportedNotificationEmails(IMessageParser<CommentReportedMessageTemplate, Comment> messageParser)
 {
     _messageParser = messageParser;
 }
 public SendOrderPartiallyRefundedEmailToCustomer(ISession session,
     IMessageParser<SendOrderPartiallyRefundedEmailToCustomerMessageTemplate, Order> messageParser)
 {
     _session = session;
     _messageParser = messageParser;
 }
 public SendOrderShippedEmailToCustomer(
     IMessageParser<SendOrderShippedEmailToCustomerMessageTemplate, Order> messageParser)
 {
     _messageParser = messageParser;
 }
 public void RegisterMessageParser(string key, IMessageParser parser)
 {
     throw new NotImplementedException();
 }
 public BackInStockNotificationTask(Site site, ISession session, IMessageParser<ProductBackInStockMessageTemplate, ProductVariant> messageParser)
 {
     _site = site;
     _session = session;
     _messageParser = messageParser;
 }
 public IncomingMessageProcessor(IMessageRepository messageRepository, ITagRepository tagRepository, IMessageParser messageParser)
     : this(messageRepository, tagRepository, messageParser, null,null)
 {
 }
Beispiel #59
0
 public CBWrapper(IMessageParser parser)
 {
     mParser = parser;
 }
 public IrcClient(IMessageParser parser, IResponseValidator responseValidator)
 {
     this.parser = parser;
     this.responseValidator = responseValidator;
 }