Skip to content

Commit 212ffc8

Browse files
committed
Moved IsRunningOnMono
1 parent 024d759 commit 212ffc8

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Hangfire.PostgreSql
6+
{
7+
internal class EnvironmentHelpers
8+
{
9+
private static bool? _isMono;
10+
11+
public static bool IsMono() =>
12+
_isMono ??= Type.GetType("Mono.Runtime") != null;
13+
}
14+
}

src/Hangfire.PostgreSql/PostgreSqlStorage.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ internal T UseTransaction<T>(DbConnection dedicatedConnection,
237237
{
238238
isolationLevel = isolationLevel ?? IsolationLevel.ReadCommitted;
239239

240-
if (!IsRunningOnMono())
240+
if (!EnvironmentHelpers.IsMono())
241241
{
242242
using (TransactionScope transaction = CreateTransaction(isolationLevel))
243243
{
@@ -319,12 +319,6 @@ private static void Current_TransactionCompleted(object sender, TransactionEvent
319319
}
320320
}
321321

322-
private static bool? _isRunningOnMono;
323-
private static bool IsRunningOnMono()
324-
{
325-
return _isRunningOnMono ??= Type.GetType("Mono.Runtime") != null;
326-
}
327-
328322
private static TransactionScope CreateTransaction(IsolationLevel? isolationLevel)
329323
{
330324
return isolationLevel != null

0 commit comments

Comments
 (0)