/// <summary> /// Gets a replacement for the InternalWatcher /// </summary> /// <returns>A new IWatcher of the same type as the InternalWatcher</returns> private IWatcher GetReplacementWatcher() { IWatcher newInternalWatcher = null; // Swallowing any exceptions that might occure when trying to get a clone of the current watcher CancellationToken cToken = _refreshTokenSource.Token; Policy.Handle <Exception>() .RetryForever((Exception ex, Int32 con) => Thread.Sleep(RefreshAttempInterval)) .Execute(() => { // If the refreshment is cancelled, place a fake as the new watcher and return. if (cToken.IsCancellationRequested) { newInternalWatcher = new FakeWatcher(); return; //Exits polly's 'Execute' method. } newInternalWatcher = (IWatcher)InternalWatcher.Clone(); // setting EnableRaisingEvents to true is where exceptions may raise so // I'm giving this clone a "test drive" before returning it to the Refresh method newInternalWatcher.EnableRaisingEvents = true; newInternalWatcher.EnableRaisingEvents = false; }); return(newInternalWatcher); }
public override Object Clone() { IWatcher clonedInternalWatcher = (IWatcher)InternalWatcher.Clone(); return(new RefreshableWatcher(clonedInternalWatcher) { RefreshAttempInterval = RefreshAttempInterval }); }
public override object Clone() { var clonedInternalWatcher = (IFileSystemWatcher)InternalWatcher.Clone(); return(new FileSystemRefreshableWatcher(clonedInternalWatcher) { RefreshAttempInterval = this.RefreshAttempInterval }); }
public override object Clone() { IFileSystemWatcher clonedEncapsWatcher = InternalWatcher.Clone() as IFileSystemWatcher; FileSystemAutoRefreshingWatcher clonedAutoRefreshingWatcher = new FileSystemAutoRefreshingWatcher(clonedEncapsWatcher); // Add current refresher's policies to the cloned one clonedAutoRefreshingWatcher.ClearPolicies(); foreach (var policy in _errorHandlingPolicies) { clonedAutoRefreshingWatcher.AddPolicy(policy); } return(clonedAutoRefreshingWatcher); }
public override Object Clone() { IWatcher clonedEncapsWatcher = InternalWatcher.Clone() as IWatcher; AutoRefreshingWatcher clonedAutoRefreshingWatcher = new AutoRefreshingWatcher(clonedEncapsWatcher); // Add current refresher's policies to the cloned one clonedAutoRefreshingWatcher.ClearPolicies(); foreach (WatcherErrorHandlingPolicy policy in _errorHandlingPolicies) { clonedAutoRefreshingWatcher.AddPolicy(policy); } return(clonedAutoRefreshingWatcher); }
public override object Clone() { var clonedPoller = (IFileSystemPoller)_poller.Clone(); var clonedEncapsWatcher = (IFileSystemWatcher)InternalWatcher.Clone(); var clonedOverseer = new FileSystemOverseer(clonedPoller, clonedEncapsWatcher) { PollerReportsDelay = this.PollerReportsDelay }; clonedOverseer.ClearPolicies(); foreach (var policy in ErrorHandlingPolicies) { clonedOverseer.AddPolicy(policy); } return(clonedOverseer); }
public override Object Clone() { IPoller clonedPoller = (IPoller)_poller.Clone(); IWatcher clonedEncapsWatcher = (IWatcher)InternalWatcher.Clone(); OverseerWatcher clonedOverseerWatcher = new OverseerWatcher(clonedPoller, clonedEncapsWatcher) { PollerReportsDelay = PollerReportsDelay }; clonedOverseerWatcher.ClearPolicies(); foreach (WatcherErrorHandlingPolicy policy in ErrorHandlingPolicies) { clonedOverseerWatcher.AddPolicy(policy); } return(clonedOverseerWatcher); }