public LockResult Lock(IStoreItem item, LockType lockType, LockScope lockScope, XElement owner, Uri lockRootUri, bool recursive, IEnumerable <int> timeouts)
        {
            // Determine the expiration based on the first time-out
            var timeout = timeouts.Cast <int?>().FirstOrDefault();

            // Determine the item's key
            var key = item.UniqueKey;

            lock (_itemLocks)
            {
                // Make sure the item is in the dictionary
                if (!_itemLocks.TryGetValue(key, out var itemLockTypeDictionary))
                {
                    _itemLocks.Add(key, itemLockTypeDictionary = new EfsStoreLockingManager.ItemLockTypeDictionary());
                }

                // Make sure there is already a lock-list for this type
                if (!itemLockTypeDictionary.TryGetValue(lockType, out var itemLockList))
                {
                    // Create a new lock-list
                    itemLockTypeDictionary.Add(lockType, itemLockList = new EfsStoreLockingManager.ItemLockList());
                }
                else
                {
                    // Check if there is already an exclusive lock
                    if (itemLockList.Any(l => l.Scope == LockScope.Exclusive))
                    {
                        return(new LockResult(DavStatusCode.Locked));
                    }
                }

                // Create the lock info object
                var itemLockInfo = new EfsStoreLockingManager.ItemLockInfo(item, lockType, lockScope, lockRootUri, recursive, owner, timeout ?? -1);

                // Add the lock
                itemLockList.Add(itemLockInfo);

                // Return the active lock
                return(new LockResult(DavStatusCode.Ok, GetActiveLockInfo(itemLockInfo)));
            }
        }
 private static ActiveLock GetActiveLockInfo(EfsStoreLockingManager.ItemLockInfo itemLockInfo)
 {
     return(new ActiveLock(itemLockInfo.Type, itemLockInfo.Scope, itemLockInfo.Recursive ? int.MaxValue : 0, itemLockInfo.Owner, itemLockInfo.Timeout, new Uri($"{TokenScheme}:{itemLockInfo.Token:D}"), itemLockInfo.LockRootUri));
 }