Ejemplo n.º 1
0
 /// <summary>
 /// Deserializes the byte array into an instance of T
 /// </summary>
 /// <param name="serializer">Serializer</param>
 /// <param name="bytes">The data to deserialize</param>
 /// <typeparam name="T">The type to instantiate</typeparam>
 /// <returns>The deserialized object</returns>
 public static T Deserialize <T>(this INoticeSerializer serializer, byte[] bytes)
 {
     if (serializer == null)
     {
         throw new ArgumentNullException(nameof(serializer));
     }
     return((T)serializer.Deserialize(typeof(T), bytes));
 }
Ejemplo n.º 2
0
        public AwardingNotifier(INoticeSerializer serializer, ILotteryMerchanterApplicationService lotteryMerchanterApplicationService, ILogger <AwardingNotifier> logger)
        {
            _serializer = serializer;
            _logger     = logger;
            _lotteryMerchanterApplicationService = lotteryMerchanterApplicationService;
            _client = new HttpClient();

            _policy = Policy.Handle <Exception>().OrResult(false).WaitAndRetryAsync(2, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
            {
                _logger.LogWarning("推送失败:{0} {1} 重试中...", ex.Result, ex.Exception?.Message);
            });
        }