public IRollbackBetCancel <T> MapRollbackBetCancel <T>(rollback_bet_cancel message, IEnumerable <CultureInfo> cultures, byte[] rawMessage) where T : ISportEvent { Contract.Requires(message != null); Contract.Ensures(Contract.Result <IRollbackBetCancel <T> >() != null); return(Contract.Result <IRollbackBetCancel <T> >()); }
/// <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_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 RollbackBetCancelEventArgs(IFeedMessageMapper messageMapper, rollback_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; }
/// <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_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 RollbackBetCancelEventArgs(IFeedMessageMapper messageMapper, rollback_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; }
/// <summary> /// Maps (converts) the provided <see cref="rollback_bet_cancel"/> instance to the <see cref="IRollbackBetCancel{T}"/> instance /// </summary> /// <param name="message">A <see cref="rollback_bet_cancel"/> instance to be mapped (converted)</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}" /> specifying the languages to which the mapped message will be translated</param> /// <param name="rawMessage">The raw message</param> /// <returns>A <see cref="IRollbackBetCancel{T}"/> instance constructed from information in the provided <see cref="rollback_bet_cancel"/></returns> public IRollbackBetCancel <T> MapRollbackBetCancel <T>(rollback_bet_cancel message, IEnumerable <CultureInfo> cultures, byte[] rawMessage) where T : ISportEvent { var culturesList = cultures as List <CultureInfo> ?? cultures.ToList(); return(new RollbackBetCancel <T>( new MessageTimestamp(message.GeneratedAt, message.SentAt, message.ReceivedAt, SdkInfo.ToEpochTime(DateTime.Now)), _producerManager.Get(message.product), GetEventForMessage <T>(URN.Parse(message.event_id), message.SportId, culturesList), message.request_idSpecified ? (long?)message.request_id : null, message.start_timeSpecified ? (long?)message.start_time : null, message.end_timeSpecified ? (long?)message.end_time : null, message.market.Select(m => GetMarketCancel(GetEventForNameProvider <T>(URN.Parse(message.event_id), message.SportId, culturesList), m, message.ProducerId, message.SportId, culturesList)), rawMessage)); }
/// <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_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 RollbackBetCancelEventArgs(IFeedMessageMapper messageMapper, rollback_bet_cancel 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; _rollbackBetCancel = GetBetCancelRollback(); }
/// <summary> /// Dispatches the <see cref="rollback_bet_cancel"/> message /// </summary> /// <param name="message">The <see cref="rollback_bet_cancel"/> message to dispatch</param> /// <param name="rawMessage">A raw message received from the feed</param> private void DispatchRollbackBetCancel(rollback_bet_cancel message, byte[] rawMessage) { var eventArgs = new RollbackBetCancelEventArgs <T>(MessageMapper, message, DefaultCultures, rawMessage); Dispatch(OnRollbackBetCancel, eventArgs, message); }