示例#1
0
        /// <summary>
        /// 收集另一个物品容器中的所有物品,并清空他。
        /// </summary>
        /// <param name="collection">物品容器</param>
        public void Collect(ItemCollection collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            lock (collection._sync)
            {
                lock ( _sync )
                {
                    foreach (var item in collection)
                    {
                        AddItemsInternal(item.ItemDescriptor, item.Quantity);
                    }

                    collection.Clear();
                    OnChanged();
                }
            }
        }