Skip to content

Commit e235cec

Browse files
committed
Add ConfigureOptions method
1 parent db53ec6 commit e235cec

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/RetryCore/RetryBuilder.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ public RetryBuilder ConfigureOptions(Action<RetryOptions> configureAction)
108108
return this;
109109
}
110110

111+
/// <summary>
112+
/// Configures the RetryOptions.
113+
/// </summary>
114+
/// <param name="option">The retry option.</param>
115+
/// <returns></returns>
116+
public RetryBuilder ConfigureOptions(RetryOptions option)
117+
{
118+
_configureAction = options =>
119+
{
120+
options.MaxTryCount = option.MaxTryCount;
121+
options.MaxTryTime = option.MaxTryTime;
122+
options.RetryInterval = option.RetryInterval;
123+
};
124+
125+
return this;
126+
}
127+
111128
/// <summary>
112129
/// Retry only on exceptions of the type.
113130
/// </summary>

src/RetryCore/RetryCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<LangVersion>latest</LangVersion>
1010

11-
<Version>0.3.1</Version>
11+
<Version>0.3.2</Version>
1212
<PackageId>$(AssemblyName)</PackageId>
1313
<Description>A library for retrying operations.</Description>
1414
<Authors>jerviscui</Authors>

test/RetryCore.Tests/RetryBuilderTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,8 @@ public async Task TryFunction_AsAsync_Test()
7878
[Fact]
7979
public void TryFunction_OverMaxTryTimeException_Test()
8080
{
81-
var r = RetryBuilder.Default.ConfigureOptions(options =>
82-
{
83-
options.MaxTryCount = int.MaxValue;
84-
options.MaxTryTime = TimeSpan.FromSeconds(1);
85-
}).Build(() =>
81+
var options = new RetryOptions { MaxTryCount = int.MaxValue, MaxTryTime = TimeSpan.FromSeconds(1) };
82+
var r = RetryBuilder.Default.ConfigureOptions(options).Build(() =>
8683
{
8784
throw new Exception();
8885
return 1;

0 commit comments

Comments
 (0)