Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsFeedSession"/> class
        /// </summary>
        /// <param name="messageReceiver"> A <see cref="IMessageReceiver"/> used to provide feed messages</param>
        /// <param name="messageProcessor">A <see cref="IFeedMessageProcessor"/> instance used to process received messages</param>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map the feed messages to messages used by the SDK</param>
        /// <param name="messageValidator">A <see cref="IFeedMessageValidator"/> instance used to validate received messages</param>
        /// <param name="messageDataExtractor">A <see cref="IMessageDataExtractor"/> instance used to extract basic message data from messages which could not be deserialized</param>
        /// <param name="dispatcherStore">A <see cref="IDispatcherStore"/> implementation used to store and access user registered dispatchers</param>
        /// <param name="messageInterest">Specifies the type of messages handled by this <see cref="OddsFeedSession"/></param>
        /// <param name="defaultCultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages as specified in the configuration</param>
        /// <param name="getRoutingKeys">Func to get appropriate routing keys based on the message interest</param>
        public OddsFeedSession(
            IMessageReceiver messageReceiver,
            IFeedMessageProcessor messageProcessor,
            IFeedMessageMapper messageMapper,
            IFeedMessageValidator messageValidator,
            IMessageDataExtractor messageDataExtractor,
            IDispatcherStore dispatcherStore,
            MessageInterest messageInterest,
            IEnumerable <CultureInfo> defaultCultures,
            Func <OddsFeedSession, IEnumerable <string> > getRoutingKeys)
            : base(messageMapper, defaultCultures)
        {
            Guard.Argument(messageReceiver, nameof(messageReceiver)).NotNull();
            Guard.Argument(messageInterest, nameof(messageInterest)).NotNull();
            Guard.Argument(messageProcessor, nameof(messageProcessor)).NotNull();
            Guard.Argument(messageValidator, nameof(messageValidator)).NotNull();
            Guard.Argument(messageDataExtractor, nameof(messageDataExtractor)).NotNull();
            Guard.Argument(dispatcherStore, nameof(dispatcherStore)).NotNull();

            MessageReceiver       = messageReceiver;
            _messageProcessor     = messageProcessor;
            _messageValidator     = messageValidator;
            _messageDataExtractor = messageDataExtractor;
            MessageInterest       = messageInterest;

            _sportSpecificDispatchers = dispatcherStore;

            _getRoutingKeys = getRoutingKeys;

            Name = char.ToUpperInvariant(MessageInterest.Name[0]) + MessageInterest.Name.Substring(1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsFeedSession"/> class
        /// </summary>
        /// <param name="messageReceiver"> A <see cref="IMessageReceiver"/> used to provide feed messages</param>
        /// <param name="messageProcessor">A <see cref="IFeedMessageProcessor"/> instance used to process received messages</param>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map the feed messages to messages used by the SDK</param>
        /// <param name="messageValidator">A <see cref="IFeedMessageValidator"/> instance used to validate received messages</param>
        /// <param name="messageDataExtractor">A <see cref="IMessageDataExtractor"/> instance used to extract basic message data from messages which could not be deserialized</param>
        /// <param name="dispatcherStore">A <see cref="IDispatcherStore"/> implementation used to store and access user registered dispatchers</param>
        /// <param name="messageInterest">Specifies the type of messages handled by this <see cref="OddsFeedSession"/></param>
        /// <param name="defaultCultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages as specified in the configuration</param>
        /// <param name="getRoutingKeys">Func to get appropriate routing keys based on the message interest</param>
        public OddsFeedSession(
            IMessageReceiver messageReceiver,
            IFeedMessageProcessor messageProcessor,
            IFeedMessageMapper messageMapper,
            IFeedMessageValidator messageValidator,
            IMessageDataExtractor messageDataExtractor,
            IDispatcherStore dispatcherStore,
            MessageInterest messageInterest,
            IEnumerable <CultureInfo> defaultCultures,
            Func <OddsFeedSession, IEnumerable <string> > getRoutingKeys)
            : base(messageMapper, defaultCultures)
        {
            Contract.Requires(messageReceiver != null);
            Contract.Requires(messageInterest != null);
            Contract.Requires(messageProcessor != null);
            Contract.Requires(messageValidator != null);
            Contract.Requires(messageDataExtractor != null);
            Contract.Requires(dispatcherStore != null);

            MessageReceiver       = messageReceiver;
            _messageProcessor     = messageProcessor;
            _messageValidator     = messageValidator;
            _messageDataExtractor = messageDataExtractor;
            MessageInterest       = messageInterest;

            _sportSpecificDispatchers = dispatcherStore;

            _getRoutingKeys = getRoutingKeys;

            Name = char.ToUpperInvariant(MessageInterest.Name[0]) + MessageInterest.Name.Substring(1);
        }
        public void Init()
        {
            var nameProviderFactoryMock    = new Mock <INameProviderFactory>();
            var nameProviderMock           = new Mock <INameProvider>();
            var mappingProviderFactoryMock = new Mock <IMarketMappingProviderFactory>();

            nameProviderFactoryMock.Setup(m => m.BuildNameProvider(It.IsAny <ISportEvent>(), It.IsAny <int>(), It.IsAny <IReadOnlyDictionary <string, string> >())).Returns(nameProviderMock.Object);

            var namedValuesCacheMock = new Mock <INamedValueCache>();

            namedValuesCacheMock.Setup(x => x.IsValueDefined(It.IsAny <int>())).Returns(true);
            namedValuesCacheMock.Setup(x => x.GetNamedValue(It.IsAny <int>())).Returns((int id) => new NamedValue(id, "somevalue"));

            var namedValuesProviderMock = new Mock <INamedValuesProvider>();

            namedValuesProviderMock.Setup(x => x.VoidReasons).Returns(namedValuesCacheMock.Object);
            namedValuesProviderMock.Setup(x => x.BetStopReasons).Returns(namedValuesCacheMock.Object);
            namedValuesProviderMock.Setup(x => x.BettingStatuses).Returns(namedValuesCacheMock.Object);

            _mapper = new FeedMessageMapper(new TestSportEventFactory(),
                                            nameProviderFactoryMock.Object,
                                            mappingProviderFactoryMock.Object,
                                            namedValuesProviderMock.Object,
                                            ExceptionHandlingStrategy.THROW,
                                            TestProducerManager.Create(),
                                            new Mock <IMarketCacheProvider>().Object,
                                            namedValuesCacheMock.Object);
            _deserializer = new Deserializer <FeedMessage>();
            _validator    = new TestFeedMessageValidator();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EntityDispatcher{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map the feed messages to messages used by the SDK</param>
        /// <param name="defaultCultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages as specified in the configuration</param>
        internal EntityDispatcher(IFeedMessageMapper messageMapper, IEnumerable <CultureInfo> defaultCultures)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(defaultCultures, nameof(defaultCultures)).NotNull().NotEmpty();

            MessageMapper   = messageMapper;
            DefaultCultures = defaultCultures as IReadOnlyCollection <CultureInfo>;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntityDispatcher{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map the feed messages to messages used by the SDK</param>
        /// <param name="defaultCultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages as specified in the configuration</param>
        internal EntityDispatcher(IFeedMessageMapper messageMapper, IEnumerable <CultureInfo> defaultCultures)
        {
            Contract.Requires(messageMapper != null);
            Contract.Requires(defaultCultures != null && defaultCultures.Any());

            MessageMapper   = messageMapper;
            DefaultCultures = defaultCultures as IReadOnlyCollection <CultureInfo>;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AliveEventArgs"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="alive"/> message received from the feed</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal AliveEventArgs(IFeedMessageMapper messageMapper, alive feedMessage, byte[] rawMessage)
        {
            Contract.Requires(messageMapper != null);
            Contract.Requires(feedMessage != null);

            _messageMapper = messageMapper;
            _feedMessage   = feedMessage;
            _rawMessage    = rawMessage;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SessionMessageManager"/> class
        /// </summary>
        public SessionMessageManager(IFeedMessageMapper messageMapper)
        {
            Contract.Requires(messageMapper != null);

            ProcessorId = Guid.NewGuid().ToString().Substring(0, 4);

            _stashedItems      = new List <StashedItem>();
            _feedMessageMapper = messageMapper;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AliveEventArgs"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="alive"/> message received from the feed</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal AliveEventArgs(IFeedMessageMapper messageMapper, alive feedMessage, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();

            _messageMapper = messageMapper;
            _feedMessage   = feedMessage;
            _rawMessage    = rawMessage;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SessionMessageManager"/> class
        /// </summary>
        public SessionMessageManager(IFeedMessageMapper messageMapper)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();

            ProcessorId = Guid.NewGuid().ToString().Substring(0, 4);

            _stashedItems      = new List <StashedItem>();
            _feedMessageMapper = messageMapper;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProducerRecoveryManagerFactory"/> class.
        /// </summary>
        /// <param name="recoveryRequestIssuer">The <see cref="IRecoveryRequestIssuer"/> instance needed when creating <see cref="IProducerRecoveryManager"/> instances</param>
        /// <param name="messageMapper">The <see cref="IFeedMessageMapper"/> instance used to create <see cref="ISessionMessageManager"/> instances</param>
        /// <param name="config">The <see cref="IOddsFeedConfiguration"/> instance used to create <see cref="IProducerRecoveryManager"/> instances</param>
        public ProducerRecoveryManagerFactory(IRecoveryRequestIssuer recoveryRequestIssuer, IFeedMessageMapper messageMapper, IOddsFeedConfiguration config)
        {
            Guard.Argument(recoveryRequestIssuer, nameof(recoveryRequestIssuer)).NotNull();
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(config, nameof(config)).NotNull();

            _recoveryRequestIssuer = recoveryRequestIssuer;
            _messageMapper         = messageMapper;
            _config = config;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProducerRecoveryManagerFactory"/> class.
        /// </summary>
        /// <param name="recoveryRequestIssuer">The <see cref="IRecoveryRequestIssuer"/> instance needed when creating <see cref="IProducerRecoveryManager"/> instances</param>
        /// <param name="messageMapper">The <see cref="IFeedMessageMapper"/> instance used to create <see cref="ISessionMessageManager"/> instances</param>
        /// <param name="config">The <see cref="IOddsFeedConfiguration"/> instance used to create <see cref="IProducerRecoveryManager"/> instances</param>
        public ProducerRecoveryManagerFactory(IRecoveryRequestIssuer recoveryRequestIssuer, IFeedMessageMapper messageMapper, IOddsFeedConfiguration config)
        {
            Contract.Requires(recoveryRequestIssuer != null);
            Contract.Requires(messageMapper != null);
            Contract.Requires(config != null);

            _recoveryRequestIssuer = recoveryRequestIssuer;
            _messageMapper         = messageMapper;
            _config = config;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SnapshotCompleteEventArgs"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="snapshot_complete"/> message received from the feed</param>
        /// <param name="interest">A <see cref="MessageInterest"/> of the session which received the message</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal SnapshotCompleteEventArgs(IFeedMessageMapper messageMapper, snapshot_complete feedMessage, MessageInterest interest, byte[] rawMessage)
        {
            Contract.Requires(messageMapper != null);
            Contract.Requires(feedMessage != null);
            Contract.Requires(interest != null);

            _messageMapper = messageMapper;
            _feedMessage   = feedMessage;
            _interest      = interest;
            _rawMessage    = rawMessage;
        }
Ejemplo n.º 13
0
        public CashOutProbabilitiesProvider(IDataProvider <cashout> dataProvider, IFeedMessageMapper messageMapper, IEnumerable <CultureInfo> defaultCultures, ExceptionHandlingStrategy exceptionStrategy)
        {
            Guard.Argument(dataProvider, nameof(dataProvider)).NotNull();
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(defaultCultures, nameof(defaultCultures)).NotNull().NotEmpty();

            _dataProvider      = dataProvider;
            _messageMapper     = messageMapper;
            _defaultCultures   = defaultCultures;
            _exceptionStrategy = exceptionStrategy;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="bet_cancel"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal BetCancelEventArgs(IFeedMessageMapper messageMapper, bet_cancel feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Contract.Requires(messageMapper != null);
            Contract.Requires(feedMessage != null);
            Contract.Requires(cultures != null && cultures.Any());

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="rollback_bet_settlement"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal RollbackBetSettlementEventArgs(IFeedMessageMapper messageMapper, rollback_bet_settlement feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Contract.Requires(messageMapper != null);
            Contract.Requires(feedMessage != null);
            Contract.Requires(cultures != null && cultures.Any());

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;
        }
        public CashOutProbabilitiesProvider(IDataProvider <cashout> dataProvider, IFeedMessageMapper messageMapper, IEnumerable <CultureInfo> defaultCultures, ExceptionHandlingStrategy exceptionStrategy)
        {
            Contract.Requires(dataProvider != null);
            Contract.Requires(messageMapper != null);
            Contract.Requires(defaultCultures != null && defaultCultures.Any());

            _dataProvider      = dataProvider;
            _messageMapper     = messageMapper;
            _defaultCultures   = defaultCultures;
            _exceptionStrategy = exceptionStrategy;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SnapshotCompleteEventArgs"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="snapshot_complete"/> message received from the feed</param>
        /// <param name="interest">A <see cref="MessageInterest"/> of the session which received the message</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal SnapshotCompleteEventArgs(IFeedMessageMapper messageMapper, snapshot_complete feedMessage, MessageInterest interest, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();
            Guard.Argument(interest, nameof(interest)).NotNull();

            _messageMapper = messageMapper;
            _feedMessage   = feedMessage;
            _interest      = interest;
            _rawMessage    = rawMessage;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntityDispatcher{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map the feed messages to messages used by the SDK</param>
        /// <param name="defaultCultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages as specified in the configuration</param>
        internal EntityDispatcher(IFeedMessageMapper messageMapper, IEnumerable <CultureInfo> defaultCultures)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            if (!defaultCultures.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(defaultCultures));
            }

            MessageMapper   = messageMapper;
            DefaultCultures = defaultCultures as IReadOnlyCollection <CultureInfo>;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="odds_change"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal OddsChangeEventArgs(IFeedMessageMapper messageMapper, odds_change feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="rollback_bet_settlement"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal RollbackBetSettlementEventArgs(IFeedMessageMapper messageMapper, rollback_bet_settlement feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="bet_stop"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal BetStopEventArgs(IFeedMessageMapper messageMapper, bet_stop feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyList <CultureInfo>;
            _rawMessage      = rawMessage;

            _betStop = GetBetStop();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="bet_cancel"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal BetCancelEventArgs(IFeedMessageMapper messageMapper, bet_cancel feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;

            _betCancel = GetBetCancel();
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="odds_change"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal OddsChangeEventArgs(IFeedMessageMapper messageMapper, odds_change feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Contract.Requires(messageMapper != null);
            Contract.Requires(feedMessage != null);
            Contract.Requires(cultures != null && cultures.Any());
            Contract.Ensures(_messageMapper != null);
            Contract.Ensures(_feedMessage != null);
            Contract.Ensures(_defaultCultures != null && _defaultCultures.Any());

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="bet_stop"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal BetStopEventArgs(IFeedMessageMapper messageMapper, bet_stop feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull();//.NotEmpty();
            if (!cultures.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(cultures));
            }


            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="rollback_bet_settlement"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal RollbackBetSettlementEventArgs(IFeedMessageMapper messageMapper, rollback_bet_settlement feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();
            if (!cultures.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(cultures));
            }

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;

            _rollbackBetSettlement = GetBetSettlementRollback();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsChangeEventArgs{T}"/> class
        /// </summary>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map feed message to the one dispatched to the user</param>
        /// <param name="feedMessage">A <see cref="odds_change"/> message received from the feed</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages to which the received message is translated</param>
        /// <param name="rawMessage">A raw message received from the feed</param>
        internal OddsChangeEventArgs(IFeedMessageMapper messageMapper, odds_change feedMessage, IEnumerable <CultureInfo> cultures, byte[] rawMessage)
        {
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(feedMessage, nameof(feedMessage)).NotNull();
            if (!cultures.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(cultures));
            }

            _messageMapper   = messageMapper;
            _feedMessage     = feedMessage;
            _defaultCultures = cultures as IReadOnlyCollection <CultureInfo>;
            _rawMessage      = rawMessage;

            _oddsChange = GetOddsChange();
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsFeedSession"/> class
        /// </summary>
        /// <param name="globalEventDispatcher">A <see cref="IGlobalEventDispatcher"/> used to dispatch global events</param>
        /// <param name="messageReceiver"> A <see cref="IMessageReceiver"/> used to provide feed messages</param>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map the feed messages to messages used by the SDK</param>
        /// <param name="messageValidator">A <see cref="IFeedMessageValidator"/> instance used to validate received messages</param>
        /// <param name="messageDataExtractor">A <see cref="IMessageDataExtractor"/> instance used to extract basic message data from messages which could not be deserialized</param>
        public FeedSystemSession(
            IGlobalEventDispatcher globalEventDispatcher,
            IMessageReceiver messageReceiver,
            IFeedMessageMapper messageMapper,
            IFeedMessageValidator messageValidator,
            IMessageDataExtractor messageDataExtractor)
        {
            Contract.Requires(globalEventDispatcher != null);
            Contract.Requires(messageReceiver != null);
            Contract.Requires(messageMapper != null);
            Contract.Requires(messageValidator != null);
            Contract.Requires(messageDataExtractor != null);

            _globalEventDispatcher = globalEventDispatcher;
            _messageReceiver       = messageReceiver;
            _messageValidator      = messageValidator;
            _messageMapper         = messageMapper;
            _messageDataExtractor  = messageDataExtractor;
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OddsFeedSession"/> class
        /// </summary>
        /// <param name="globalEventDispatcher">A <see cref="IGlobalEventDispatcher"/> used to dispatch global events</param>
        /// <param name="messageReceiver"> A <see cref="IMessageReceiver"/> used to provide feed messages</param>
        /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map the feed messages to messages used by the SDK</param>
        /// <param name="messageValidator">A <see cref="IFeedMessageValidator"/> instance used to validate received messages</param>
        /// <param name="messageDataExtractor">A <see cref="IMessageDataExtractor"/> instance used to extract basic message data from messages which could not be deserialized</param>
        public FeedSystemSession(
            IGlobalEventDispatcher globalEventDispatcher,
            IMessageReceiver messageReceiver,
            IFeedMessageMapper messageMapper,
            IFeedMessageValidator messageValidator,
            IMessageDataExtractor messageDataExtractor)
        {
            Guard.Argument(globalEventDispatcher, nameof(globalEventDispatcher)).NotNull();
            Guard.Argument(messageReceiver, nameof(messageReceiver)).NotNull();
            Guard.Argument(messageMapper, nameof(messageMapper)).NotNull();
            Guard.Argument(messageValidator, nameof(messageValidator)).NotNull();
            Guard.Argument(messageDataExtractor, nameof(messageDataExtractor)).NotNull();

            _globalEventDispatcher = globalEventDispatcher;
            _messageReceiver       = messageReceiver;
            _messageValidator      = messageValidator;
            _messageMapper         = messageMapper;
            _messageDataExtractor  = messageDataExtractor;
        }
        static MapEntityTestBase()
        {
            var nameProviderFactoryMock = new Mock <INameProviderFactory>();
            var nameProviderMock        = new Mock <INameProvider>();

            nameProviderFactoryMock.Setup(m => m.BuildNameProvider(It.IsAny <ICompetition>(), It.IsAny <int>(), It.IsAny <IReadOnlyDictionary <string, string> >())).Returns(nameProviderMock.Object);

            var voidReasonCache = new NamedValueCache(new NamedValueDataProvider(TestData.RestXmlPath + @"\void_reasons.xml", new TestDataFetcher(), "void_reason"), ExceptionHandlingStrategy.THROW);

            var namedValuesProviderMock = new Mock <INamedValuesProvider>();

            namedValuesProviderMock.Setup(x => x.VoidReasons).Returns(voidReasonCache);

            Mapper = new FeedMessageMapper(
                new TestSportEventFactory(),
                nameProviderFactoryMock.Object,
                new Mock <IMarketMappingProviderFactory>().Object,
                namedValuesProviderMock.Object,
                ExceptionHandlingStrategy.THROW,
                TestProducerManager.Create(),
                new Mock <IMarketCacheProvider>().Object,
                voidReasonCache);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpecificEntityDispatcher{T}"/> class.
 /// </summary>
 /// <param name="messageMapper">A <see cref="IFeedMessageMapper"/> used to map the feed messages to messages used by the SDK</param>
 /// <param name="defaultCultures">A <see cref="IEnumerable{CultureInfo}"/> specifying the default languages as specified in the configuration</param>
 internal SpecificEntityDispatcher(IFeedMessageMapper messageMapper, IEnumerable <CultureInfo> defaultCultures)
     : base(messageMapper, defaultCultures)
 {
 }