mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-01-01 10:32:09 +01:00
Moved source code under src folder - massive change
This commit is contained in:
38
src/Marr.Data/UnitOfWorkSharedContext.cs
Normal file
38
src/Marr.Data/UnitOfWorkSharedContext.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
namespace Marr.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Works in conjunction with the UnitOfWork to create a new
|
||||
/// shared context that will preserve a single IDataMapper.
|
||||
/// </summary>
|
||||
public class UnitOfWorkSharedContext : IDisposable
|
||||
{
|
||||
private UnitOfWork _mgr;
|
||||
private bool _isParentContext;
|
||||
|
||||
public UnitOfWorkSharedContext(UnitOfWork mgr)
|
||||
{
|
||||
_mgr = mgr;
|
||||
|
||||
if (_mgr.IsShared)
|
||||
{
|
||||
_isParentContext = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isParentContext = true;
|
||||
_mgr.IsShared = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isParentContext)
|
||||
{
|
||||
_mgr.IsShared = false;
|
||||
_mgr.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user