Files
WireMock.Net-wiremock/src/WireMock.Net/Util/FileHelper.cs
Stef Heyenrath 93682c9bbf Handlebars Extension (#286)
* wip

* HandlebarsRegistrationCallback

* HandlebarsContextFactoryTests

* 1.0.21.0

* fix sonar

* LocalFileSystemHandler

* readme

* Fix System.IO.IOException
2019-07-03 18:37:22 +02:00

36 lines
940 B
C#

using JetBrains.Annotations;
using System.Threading;
using WireMock.Handlers;
using WireMock.Validation;
namespace WireMock.Util
{
internal static class FileHelper
{
private const int NumberOfRetries = 3;
private const int DelayOnRetry = 500;
public static bool TryReadMappingFileWithRetryAndDelay([NotNull] IFileSystemHandler handler, [NotNull] string path, out string value)
{
Check.NotNull(handler, nameof(handler));
Check.NotNullOrEmpty(path, nameof(path));
value = null;
for (int i = 1; i <= NumberOfRetries; ++i)
{
try
{
value = handler.ReadMappingFile(path);
return true;
}
catch
{
Thread.Sleep(DelayOnRetry);
}
}
return false;
}
}
}