mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-15 01:23:53 -07:00
added marr.datamapper source code for easy debugging.
This commit is contained in:
parent
58a05fcef8
commit
3cdff3bb71
96 changed files with 9198 additions and 363 deletions
41
Marr.Data/UnitOfWorkSharedContext.cs
Normal file
41
Marr.Data/UnitOfWorkSharedContext.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue