private static RetryLogicState <TReturnTo> CloneSync <TReturnFrom, TReturnTo>(Func <TReturnTo> action, RetryLogicState <TReturnFrom> source) { var target = new RetryLogicState <TReturnTo>(action); target = source.Clone <TReturnTo>(target); return(target); }
//TODO : plug it ////public TReturn Result { get; set; } ////public int ExceptionsCatched { get; set; } ////public bool Succeed { get; set; } internal static RetryLogicState <Nothing> BeginPrepare() { var state = new RetryLogicState <Nothing>(); state.isPreparing = true; return(state); }
internal RetryLogicState <TReturnTo> Clone <TReturnTo>(RetryLogicState <TReturnTo> target) { target.numberOfAttempts = this.numberOfAttempts; target.intervalDelay = this.intervalDelay; target.intervalStrategy = this.intervalStrategy; target.scaleFactor = this.scaleFactor; target.traceRetryEvents = this.traceRetryEvents; target.onFailureContinue = this.onFailureContinue; target.exceptions = new List <Type>(this.exceptions); target.onExceptionCallbacks = new Dictionary <Type, Action <Exception> >(this.onExceptionCallbacks.Count); target.onFailureCallbacks = new List <Action>(this.onFailureCallbacks.Count); ////target.isFrozen = this.isFrozen; // do not clone dat target.isPreparing = this.isPreparing; foreach (var pair in this.onExceptionCallbacks) { target.onExceptionCallbacks.Add(pair.Key, pair.Value); } this.onFailureCallbacks.ToList().ForEach(c => target.onFailureCallbacks.Add(c)); return(target); }