示例#1
0
        private ILocker GetAvailableLocker(Size size)
        {
            ILocker result = null;

            if (size == Size.Small && SmallLockers.Count > 0)
            {
                result = SmallLockers.Dequeue();
            }

            if (result == null && size == Size.Medium && MediumLockers.Count > 0)
            {
                result = MediumLockers.Dequeue();
            }

            if (result == null && size == Size.Large && LargeLockers.Count > 0)
            {
                result = LargeLockers.Dequeue();
            }

            if (result == null && size == Size.XLarge && XLargeLockers.Count > 0)
            {
                result = XLargeLockers.Dequeue();
            }

            if (result == null)
            {
                throw new Exception("All lockers are full");
            }

            return(result);
        }