예제 #1
0
        /// <summary>
        ///		Removes the first occurrence of a specific <see cref="PaymentItem"/> from the <c>PaymentItemCollection</c>.
        /// </summary>
        /// <param name="item">The <see cref="PaymentItem"/> to remove from the <c>PaymentItemCollection</c>.</param>
        /// <exception cref="ArgumentException">
        ///		The specified <see cref="PaymentItem"/> was not found in the <c>PaymentItemCollection</c>.
        /// </exception>
        public virtual void Remove(PaymentItem item)
        {
            int i = IndexOf(item);

            if (i < 0)
            {
                throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
            }

            ++m_version;
            RemoveAt(i);
        }
예제 #2
0
        /// <summary>
        ///		Adds a <see cref="PaymentItem"/> to the end of the <c>PaymentItemCollection</c>.
        /// </summary>
        /// <param name="item">The <see cref="PaymentItem"/> to be added to the end of the <c>PaymentItemCollection</c>.</param>
        /// <returns>The index at which the value has been added.</returns>
        public virtual int Add(PaymentItem item)
        {
            if (m_count == m_array.Length)
            {
                EnsureCapacity(m_count + 1);
            }

            m_array[m_count] = item;
            m_version++;

            return(m_count++);
        }
예제 #3
0
            public override void Remove(PaymentItem x)
            {
                rwLock.AcquireWriterLock(timeout);

                try
                {
                    collection.Remove(x);
                }
                finally
                {
                    rwLock.ReleaseWriterLock();
                }
            }
예제 #4
0
            public override void Insert(int pos, PaymentItem x)
            {
                rwLock.AcquireWriterLock(timeout);

                try
                {
                    collection.Insert(pos, x);
                }
                finally
                {
                    rwLock.ReleaseWriterLock();
                }
            }
예제 #5
0
            public override int IndexOf(PaymentItem x)
            {
                int result = 0;

                rwLock.AcquireReaderLock(timeout);

                try
                {
                    result = collection.IndexOf(x);
                }
                finally
                {
                    rwLock.ReleaseReaderLock();
                }

                return(result);
            }
예제 #6
0
            public override bool Contains(PaymentItem x)
            {
                bool result = false;

                rwLock.AcquireReaderLock(timeout);

                try
                {
                    result = collection.Contains(x);
                }
                finally
                {
                    rwLock.ReleaseReaderLock();
                }

                return(result);
            }
예제 #7
0
            public override int Add(PaymentItem x)
            {
                int result = 0;

                rwLock.AcquireWriterLock(timeout);

                try
                {
                    result = collection.Add(x);
                }
                finally
                {
                    rwLock.ReleaseWriterLock();
                }

                return(result);
            }
예제 #8
0
        /// <summary>
        ///		Removes the element at the specified index of the <c>PaymentItemCollection</c>.
        /// </summary>
        /// <param name="index">The zero-based index of the element to remove.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///		<para><paramref name="index"/> is less than zero</para>
        ///		<para>-or-</para>
        ///		<para><paramref name="index"/> is equal to or greater than <see cref="PaymentItemCollection.Count"/>.</para>
        /// </exception>
        public virtual void RemoveAt(int index)
        {
            ValidateIndex(index);             // throws

            m_count--;

            if (index < m_count)
            {
                Array.Copy(m_array, index + 1, m_array, index, m_count - index);
            }

            // We can't set the deleted entry equal to null, because it might be a value type.
            // Instead, we'll create an empty single-element array of the right type and copy it
            // over the entry we want to erase.
            PaymentItem[] temp = new PaymentItem[1];
            Array.Copy(temp, 0, m_array, m_count, 1);
            m_version++;
        }
예제 #9
0
        /// <summary>
        ///		Inserts an element into the <c>PaymentItemCollection</c> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
        /// <param name="item">The <see cref="PaymentItem"/> to insert.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///		<para><paramref name="index"/> is less than zero</para>
        ///		<para>-or-</para>
        ///		<para><paramref name="index"/> is equal to or greater than <see cref="PaymentItemCollection.Count"/>.</para>
        /// </exception>
        public virtual void Insert(int index, PaymentItem item)
        {
            ValidateIndex(index, true);             // throws

            if (m_count == m_array.Length)
            {
                EnsureCapacity(m_count + 1);
            }

            if (index < m_count)
            {
                Array.Copy(m_array, index, m_array, index + 1, m_count - index);
            }

            m_array[index] = item;
            m_count++;
            m_version++;
        }
예제 #10
0
 public override void Remove(PaymentItem x)
 {
     throw new NotSupportedException("This is a Read Only Collection and can not be modified");
 }
예제 #11
0
 public override int IndexOf(PaymentItem x)
 {
     return(m_collection.IndexOf(x));
 }
예제 #12
0
 public override bool Contains(PaymentItem x)
 {
     return(m_collection.Contains(x));
 }