-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Debugger proxies for resilience strategies (#1379)
- Loading branch information
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace Polly; | ||
|
||
public abstract partial class ResilienceStrategy | ||
{ | ||
internal sealed class DebuggerProxy | ||
{ | ||
private readonly ResilienceStrategy _resilienceStrategy; | ||
|
||
public DebuggerProxy(ResilienceStrategy resilienceStrategy) => _resilienceStrategy = resilienceStrategy; | ||
|
||
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] | ||
public IEnumerable<ResilienceStrategy> Strategies => UnwrapStrategies(_resilienceStrategy); | ||
|
||
private IEnumerable<ResilienceStrategy> UnwrapStrategies(ResilienceStrategy strategy) | ||
{ | ||
if (strategy is ResilienceStrategyPipeline pipeline) | ||
{ | ||
return pipeline.Strategies; | ||
} | ||
|
||
if (strategy is ReloadableResilienceStrategy reloadableResilienceStrategy) | ||
{ | ||
var list = new List<ResilienceStrategy> | ||
{ | ||
strategy | ||
}; | ||
list.AddRange(UnwrapStrategies(reloadableResilienceStrategy.Strategy)); | ||
|
||
return list; | ||
} | ||
|
||
return new[] { strategy }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Polly.Core/ResilienceStrategy.TResult.DebuggerProxy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Polly; | ||
|
||
public partial class ResilienceStrategy<TResult> | ||
{ | ||
internal sealed class DebuggerProxy | ||
{ | ||
private readonly ResilienceStrategy.DebuggerProxy _proxy; | ||
|
||
public DebuggerProxy(ResilienceStrategy<TResult> strategy) => _proxy = new ResilienceStrategy.DebuggerProxy(strategy.Strategy); | ||
|
||
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] | ||
public IEnumerable<ResilienceStrategy> Strategies => _proxy.Strategies; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters