Esempio n. 1
0
 private void WriteSportEntity(string msgType, ISportEvent message, long timestamp)
 {
     _log.LogDebug($"{msgType.Replace("`1", string.Empty)} message for eventId {message.Id}. Timestamp={timestamp}.");
 }
        /// <summary>
        ///     Builds and returns a <see cref="INameExpression" /> instance which can be used to generate name from the provided
        ///     expression
        /// </summary>
        /// <param name="sportEvent">A <see cref="ISportEvent" /> instance representing associated sport @event</param>
        /// <param name="specifiers">
        ///     A <see cref="IReadOnlyDictionary{String, String}" /> representing specifiers of the associated
        ///     market
        /// </param>
        /// <param name="operator">A <see cref="string" /> specifying the operator for which to build the expression</param>
        /// <param name="operand">An operand for the built expression</param>
        /// <returns>The constructed <see cref="INameExpression" /> instance</returns>
        public INameExpression BuildExpression(ISportEvent sportEvent, IReadOnlyDictionary <string, string> specifiers,
                                               string @operator, string operand)
        {
            if (sportEvent == null)
            {
                throw new ArgumentNullException(nameof(sportEvent));
            }
            if (string.IsNullOrEmpty(operand))
            {
                throw new ArgumentNullException(nameof(operand));
            }

            if (@operator == null)
            {
                EnsureSpecifiersNotNullOrEmpty(specifiers);
                Contract.Assume(specifiers != null && specifiers.Any());
                return(new CardinalNameExpression(_operandFactory.BuildOperand(specifiers, operand)));
            }

            switch (Array.IndexOf(NameExpressionHelper.DefinedOperators, @operator))
            {
            case 0:     //+
            {
                EnsureSpecifiersNotNullOrEmpty(specifiers);
                Contract.Assume(specifiers != null && specifiers.Any());
                return(new PlusNameExpression(_operandFactory.BuildOperand(specifiers, operand)));
            }

            case 1:     //-
            {
                EnsureSpecifiersNotNullOrEmpty(specifiers);
                Contract.Assume(specifiers != null && specifiers.Any());
                return(new MinusNameExpression(_operandFactory.BuildOperand(specifiers, operand)));
            }

            case 2:     //$
            {
                return(BuildEntityNameExpression(operand, sportEvent));
            }

            case 3:     //!
            {
                EnsureSpecifiersNotNullOrEmpty(specifiers);
                Contract.Assume(specifiers != null && specifiers.Any());
                return(new OrdinalNameExpression(_operandFactory.BuildOperand(specifiers, operand)));
            }

            case 4:     //%
            {
                EnsureSpecifiersNotNullOrEmpty(specifiers);
                Contract.Assert(specifiers != null && specifiers.Any());
                return(new PlayerProfileExpression(_profileCache,
                                                   _operandFactory.BuildOperand(specifiers, operand)));
            }

            default:
            {
                throw new ArgumentException(
                          $"Operator {@operator} is not supported. Supported operators are: {string.Join(",", NameExpressionHelper.DefinedOperators)}",
                          nameof(@operator));
            }
            }
        }
 private void WriteSportEntity(string msgType, ISportEvent message)
 {
     _log.LogInformation($"{msgType.Replace("`1", string.Empty)} message for eventId {message.Id}");
 }
 private void WriteLowSportEntity(string msgType, ISportEvent message)
 {
     _log.Debug($"LOW: {msgType.Replace("`1", string.Empty)} message for eventId: {message.Id}");
 }
 /// <summary>
 /// Builds and returns a new instance of the <see cref="INameProvider" />
 /// </summary>
 /// <param name="sportEvent">A <see cref="ISportEvent" /> instance representing associated sport @event</param>
 /// <param name="marketId">A market identifier, identifying the market associated with the returned instance</param>
 /// <param name="specifiers">A <see cref="IReadOnlyDictionary{String, String}" /> representing specifiers of the associated market</param>
 /// <returns>INameProvider</returns>
 public INameProvider BuildNameProvider(ISportEvent sportEvent, int marketId, IReadOnlyDictionary <string, string> specifiers)
 {
     return(new NameProvider(_marketCacheProvider, _profileCache, _expressionFactory, sportEvent, marketId, specifiers, _exceptionStrategy));
 }
Esempio n. 6
0
 private void WriteHighSportEntity(string msgType, ISportEvent message)
 {
     Console.WriteLine($"HIGH: {msgType.Replace("`1", string.Empty)} message for eventId: {message.Id}");
 }
 /// <summary>
 /// Builds and returns a new instance of the <see cref="INameProvider" />
 /// </summary>
 /// <param name="sportEvent">A <see cref="ISportEvent" /> instance representing associated sport @event</param>
 /// <param name="marketId">A market identifier, identifying the market associated with the returned instance</param>
 /// <param name="specifiers">A <see cref="IReadOnlyDictionary{String, String}" /> representing specifiers of the associated market</param>
 /// <param name="producer">A <see cref="IProducer"/> of the <see cref="ISportEvent"/></param>
 /// <param name="sportId">A sportId of the <see cref="ISportEvent"/></param>
 /// <returns>Returns an instance of <see cref="IMarketMappingProvider"/></returns>
 public IMarketMappingProvider BuildMarketMappingProvider(ISportEvent sportEvent, int marketId, IReadOnlyDictionary <string, string> specifiers, IProducer producer, URN sportId)
 {
     return(new MarketMappingProvider(_marketCacheProvider, _eventStatusCache, sportEvent, marketId, specifiers, producer, sportId, _exceptionStrategy, _producerManager));
 }
Esempio n. 8
0
 public FMessage(long timestamp, ISportEvent @event, string msgType)
 {
     Timestamp = timestamp;
     Event     = @event;
     MsgType   = msgType;
 }