コード例 #1
0
ファイル: RetryAdvice.cs プロジェクト: Oragon/Oragon.Spring
 private static void Sleep(RetryExceptionHandler handler, IDictionary <string, object> callContextDictionary, SleepHandler sleepHandler)
 {
     if (handler.IsDelayBased)
     {
         sleepHandler(handler.DelayTimeSpan);
     }
     else
     {
         try
         {
             IExpression expression = Expression.Parse(handler.DelayRateExpression);
             object      result     = expression.GetValue(null, callContextDictionary);
             decimal     d          = decimal.Parse(result.ToString());
             decimal     rounded    = decimal.Round(d * 1000, 0);
             TimeSpan    duration   = TimeSpan.FromMilliseconds(decimal.ToDouble(rounded));
             sleepHandler(duration);
         }
         catch (InvalidCastException e)
         {
             log.Warn("Was not able to cast expression to decimal [" + handler.DelayRateExpression + "]. Sleeping for 1 second", e);
             sleepHandler(new TimeSpan(0, 0, 1));
         }
         catch (Exception e)
         {
             log.Warn("Was not able to evaluate rate expression [" + handler.DelayRateExpression + "]. Sleeping for 1 second", e);
             sleepHandler(new TimeSpan(0, 0, 1));
         }
     }
 }
コード例 #2
0
ファイル: RetryAdvice.cs プロジェクト: smnbss/spring-net
 /// <summary>
 /// Creates a new RetryAdvice instance, using any arbitrary callback for delaying retries
 /// </summary>
 public RetryAdvice(SleepHandler sleepHandler)
 {
     this.sleepHandler = sleepHandler;
 }
コード例 #3
0
ファイル: RetryAdvice.cs プロジェクト: Oragon/Oragon.Spring
 /// <summary>
 /// Creates a new RetryAdvice instance, using any arbitrary callback for delaying retries
 /// </summary>
 public RetryAdvice(SleepHandler sleepHandler)
 {
     this.sleepHandler = sleepHandler;
 }
コード例 #4
0
ファイル: RetryAdvice.cs プロジェクト: smnbss/spring-net
 private static void Sleep(RetryExceptionHandler handler, IDictionary callContextDictionary, SleepHandler sleepHandler)
 {
     if (handler.IsDelayBased)
     {
         sleepHandler(handler.DelayTimeSpan);
     }
     else
     {
         try
         {
             IExpression expression = Expression.Parse(handler.DelayRateExpression);
             object result = expression.GetValue(null, callContextDictionary);
             decimal d = decimal.Parse(result.ToString());
             decimal rounded = decimal.Round(d*1000,0);
             TimeSpan duration = TimeSpan.FromMilliseconds(decimal.ToDouble(rounded));
             sleepHandler(duration);
         }
         catch (InvalidCastException e)
         {
             log.Warn("Was not able to cast expression to decimal [" + handler.DelayRateExpression + "]. Sleeping for 1 second", e);
             sleepHandler(new TimeSpan(0,0,1));
         }
         catch (Exception e)
         {
             log.Warn("Was not able to evaluate rate expression [" + handler.DelayRateExpression + "]. Sleeping for 1 second", e);
             sleepHandler(new TimeSpan(0,0,1));
         }
     }
 }