public IMultiObjectLock Lock(ILockable[] list) { if (currentLock != null) { throw new LockException("Attempting to nest MultiObjectLock"); } currentLock = this; lockedObjects = new List <object>(list.Length); SortLocks(list); // ReSharper disable once ForCanBeConvertedToForeach for (int i = 0; i < list.Length; ++i) { var lockObj = list[i].Lock; if (lockObj == null) { Logger.Warn("Received a null Lock obj when trying to lock object type {0} with hash {1}", list[i].GetType().FullName, list[i].Hash); continue; } lockEnter(lockObj); lockedObjects.Add(lockObj); } // Initialize transaction dbManager.GetThreadTransaction(); return(this); }
public static void ClearCurrentLock() { currentLock = null; }