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)
        {
            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);
        }
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)
        {
            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);
        }