TableColumnCollection.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / TableColumnCollection.cs / 1305600 / TableColumnCollection.cs

                            //---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
// File: TableColumnCollection.cs 
//
// Description: Collection of TableColumn objects. 
// 
//---------------------------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using MS.Internal.Documents; 

namespace System.Windows.Documents 
{ 
    /// 
    /// A TableColumnCollection is an ordered collection of TableColumns. 
    /// 
    /// 
    /// TableColumnCollection provides public access for TableColumns
    /// reading and manipulating. 
    /// 
    public sealed class TableColumnCollection : IList, IList 
    { 

        //----------------------------------------------------- 
        //
        //  Constructors
        //
        //----------------------------------------------------- 

        #region Constructors 
 
        internal TableColumnCollection(Table owner)
        { 
            _columnCollection = new TableColumnCollectionInternal(owner);
        }

        #endregion Constructors 

        //------------------------------------------------------ 
        // 
        //  Public Methods
        // 
        //-----------------------------------------------------

        #region Public Methods
 
        /// 
        ///  
        ///  
        /// 
        ///  
        /// 
        /// 
        /// 
        ///  
        /// 
        ///  
        ///  
        /// 
        ///  
        public void CopyTo(Array array, int index)
        {
            _columnCollection.CopyTo(array, index);
        } 

        ///  
        /// Strongly typed version of ICollection.CopyTo. 
        /// 
        ///  
        /// 
        /// 
        /// 
        ///  
        /// 
        ///  
        ///  
        /// 
        ///  
        /// 
        /// 
        /// 
        ///  
        public void CopyTo(TableColumn[] array, int index)
        { 
            _columnCollection.CopyTo(array, index); 
        }
 
        /// 
        ///     
        /// 
        IEnumerator IEnumerable.GetEnumerator() 
        {
            return _columnCollection.GetEnumerator(); 
        } 

        ///  
        ///     
        /// 
        IEnumerator IEnumerable.GetEnumerator()
        { 
            return ((IEnumerable)_columnCollection).GetEnumerator();
        } 
 
        /// 
        /// Appends a TableColumn to the end of the TableColumnCollection. 
        /// 
        /// The TableColumn to be added to the end of the TableColumnCollection.
        /// The TableColumnCollection index at which the TableColumn has been added.
        /// Adding a null is prohibited. 
        /// 
        /// If the item value is null. 
        ///  
        /// 
        /// If the new child already has a parent. 
        /// 
        public void Add(TableColumn item)
        {
            _columnCollection.Add(item); 
        }
 
        ///  
        /// Removes all elements from the TableColumnCollection.
        ///  
        /// 
        /// Count is set to zero. Capacity remains unchanged.
        /// To reset the capacity of the TableColumnCollection, call TrimToSize
        /// or set the Capacity property directly. 
        /// 
        public void Clear() 
        { 
            _columnCollection.Clear();
        } 

        /// 
        /// Determines whether a TableColumn is in the TableColumnCollection.
        ///  
        /// The TableColumn to locate in the TableColumnCollection.
        /// The value can be a null reference. 
        /// true if TableColumn is found in the TableColumnCollection; 
        /// otherwise, false.
        public bool Contains(TableColumn item) 
        {
            return _columnCollection.Contains(item);
        }
 
        /// 
        /// Returns the zero-based index of the TableColumn. If the TableColumn is not 
        /// in the TableColumnCollection, -1 is returned. 
        /// 
        /// The TableColumn to locate in the TableColumnCollection. 
        public int IndexOf(TableColumn item)
        {
            return _columnCollection.IndexOf(item);
        } 

        ///  
        /// Inserts a TableColumn into the TableColumnCollection at the specified index. 
        /// 
        /// The zero-based index at which value should be inserted. 
        /// The TableColumn to insert. 
        /// 
        /// indexc> is less than zero.
        /// -or- 
        /// index is greater than Count.
        ///  
        ///  
        /// If the item value is null.
        ///  
        /// 
        /// If Count already equals Capacity, the capacity of the
        /// TableColumnCollection is increased before the new TableColumn is inserted.
        /// 
        /// If index is equal to Count, TableColumn is added to the
        /// end of TableColumnCollection. 
        /// 
        /// The TableColumns that follow the insertion point move down to
        /// accommodate the new TableColumn. The indexes of the TableColumns that are 
        /// moved are also updated.
        /// 
        public void Insert(int index, TableColumn item)
        { 
            _columnCollection.Insert(index, item);
        } 
 
        /// 
        /// Removes the specified TableColumn from the TableColumnCollection. 
        /// 
        /// The TableColumn to remove from the TableColumnCollection.
        /// 
        /// If the item value is null. 
        /// 
        ///  
        /// If the specified TableColumn is not in this collection. 
        /// 
        ///  
        /// The TableColumns that follow the removed TableColumn move up to occupy
        /// the vacated spot. The indices of the TableColumns that are moved
        /// also updated.
        ///  
        public bool Remove(TableColumn item)
        { 
            return _columnCollection.Remove(item); 
        }
 
        /// 
        /// Removes the TableColumn at the specified index.
        /// 
        /// The zero-based index of the TableColumn to remove. 
        /// 
        /// index is less than zero 
        /// - or - 
        /// index is equal or greater than count.
        ///  
        /// 
        /// The TableColumns that follow the removed TableColumn move up to occupy
        /// the vacated spot. The indices of the TableColumns that are moved
        /// also updated. 
        /// 
        public void RemoveAt(int index) 
        { 
            _columnCollection.RemoveAt(index);
        } 


        /// 
        /// Removes a range of TableColumns from the TableColumnCollection. 
        /// 
        /// The zero-based index of the range 
        /// of TableColumns to remove 
        /// The number of TableColumns to remove.
        ///  
        /// index is less than zero.
        /// -or-
        /// count is less than zero.
        ///  
        /// 
        /// index and count do not denote a valid range of TableColumns in the TableColumnCollection. 
        ///  
        /// 
        /// The TableColumns that follow the removed TableColumns move up to occupy 
        /// the vacated spot. The indices of the TableColumns that are moved are
        /// also updated.
        /// 
        public void RemoveRange(int index, int count) 
        {
            _columnCollection.RemoveRange(index, count); 
        } 

        ///  
        /// Sets the capacity to the actual number of elements in the TableColumnCollection.
        /// 
        /// 
        /// This method can be used to minimize a TableColumnCollection's memory overhead 
        /// if no new elements will be added to the collection.
        /// 
        /// To completely clear all elements in a TableColumnCollection, call the Clear method 
        /// before calling TrimToSize.
        ///  
        public void TrimToSize()
        {
            _columnCollection.TrimToSize();
        } 

        #endregion Public Methods 
 
        //--------------------------------------------------------------------
        // 
        //  IList Members
        //
        //--------------------------------------------------------------------
 
        #region IList Members
 
        int IList.Add(object value) 
        {
            TableColumn item = value as TableColumn; 

            if (item == null)
            {
                throw new ArgumentException(SR.Get(SRID.TableCollectionElementTypeExpected, typeof(TableColumn).Name), "value"); 
            }
 
            return ((IList)_columnCollection).Add(value); 
        }
 
        void IList.Clear()
        {
            this.Clear();
        } 

        bool IList.Contains(object value) 
        { 
            return ((IList)_columnCollection).Contains(value);
        } 

        int IList.IndexOf(object value)
        {
            return ((IList)_columnCollection).IndexOf(value); 
        }
 
        void IList.Insert(int index, object value) 
        {
            ((IList)_columnCollection).Insert(index, value); 
        }

        bool IList.IsFixedSize
        { 
            get
            { 
                return ((IList)_columnCollection).IsFixedSize; 
            }
        } 

        bool IList.IsReadOnly
        {
            get 
            {
                return ((IList)_columnCollection).IsReadOnly; 
            } 
        }
 
        void IList.Remove(object value)
        {
            ((IList)_columnCollection).Remove(value);
        } 

        void IList.RemoveAt(int index) 
        { 
            ((IList)_columnCollection).RemoveAt(index);
        } 

        object IList.this[int index]
        {
            get 
            {
                return ((IList)_columnCollection)[index]; 
            } 

            set 
            {
                ((IList)_columnCollection)[index] = value;
            }
        } 

        #endregion IList Members 
 

        //----------------------------------------------------- 
        //
        //  Public Properties
        //
        //------------------------------------------------------ 

        #region Public Properties 
 
        /// 
        ///  
        /// 
        public int Count
        {
            get 
            {
                return _columnCollection.Count; 
            } 
        }
 
        /// 
        ///     
        ///     
        ///  
        public bool IsReadOnly  //  bool IList.IsReadOnly {get;}; bool ICollection.IsReadOnly {get;}
        { 
            get 
            {
                return _columnCollection.IsReadOnly; 
            }
        }

        ///  
        /// 
        ///  
        /// Always returns false. 
        /// 
        ///  
        public bool IsSynchronized
        {
            get
            { 
                return _columnCollection.IsSynchronized;
            } 
        } 

        ///  
        /// 
        /// 
        public object SyncRoot
        { 
            get
            { 
                return _columnCollection.SyncRoot; 
            }
        } 

        /// 
        /// Gets or sets the number of elements that the TableColumnCollection can contain.
        ///  
        /// 
        /// The number of elements that the TableColumnCollection can contain. 
        ///  
        /// 
        /// Capacity is the number of elements that the TableColumnCollection is capable of storing. 
        /// Count is the number of Visuals that are actually in the TableColumnCollection.
        ///
        /// Capacity is always greater than or equal to Count. If Count exceeds
        /// Capacity while adding elements, the capacity of the TableColumnCollection is increased. 
        ///
        /// By default the capacity is 8. 
        ///  
        /// 
        /// Capacity is set to a value that is less than Count. 
        /// 
        /// 
        public int Capacity
        { 
            get
            { 
                return _columnCollection.PrivateCapacity; 
            }
            set 
            {
                _columnCollection.PrivateCapacity = value;
            }
        } 

        ///  
        /// Indexer for the TableColumnCollection. Gets the TableColumn stored at the 
        /// zero-based index of the TableColumnCollection.
        ///  
        /// This property provides the ability to access a specific TableColumn in the
        /// TableColumnCollection by using the following systax: TableColumn myTableColumn = myTableColumnCollection[index].
        /// 
        ///  
        /// index is less than zero -or- index is equal to or greater than Count.
        ///  
        public TableColumn this[int index] 
        {
            get 
            {
                return _columnCollection[index];
            }
            set 
            {
                _columnCollection[index] = value; 
            } 
        }
 
        #endregion Public Properties


        private TableColumnCollectionInternal _columnCollection; 
    }
 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
// File: TableColumnCollection.cs 
//
// Description: Collection of TableColumn objects. 
// 
//---------------------------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using MS.Internal.Documents; 

namespace System.Windows.Documents 
{ 
    /// 
    /// A TableColumnCollection is an ordered collection of TableColumns. 
    /// 
    /// 
    /// TableColumnCollection provides public access for TableColumns
    /// reading and manipulating. 
    /// 
    public sealed class TableColumnCollection : IList, IList 
    { 

        //----------------------------------------------------- 
        //
        //  Constructors
        //
        //----------------------------------------------------- 

        #region Constructors 
 
        internal TableColumnCollection(Table owner)
        { 
            _columnCollection = new TableColumnCollectionInternal(owner);
        }

        #endregion Constructors 

        //------------------------------------------------------ 
        // 
        //  Public Methods
        // 
        //-----------------------------------------------------

        #region Public Methods
 
        /// 
        ///  
        ///  
        /// 
        ///  
        /// 
        /// 
        /// 
        ///  
        /// 
        ///  
        ///  
        /// 
        ///  
        public void CopyTo(Array array, int index)
        {
            _columnCollection.CopyTo(array, index);
        } 

        ///  
        /// Strongly typed version of ICollection.CopyTo. 
        /// 
        ///  
        /// 
        /// 
        /// 
        ///  
        /// 
        ///  
        ///  
        /// 
        ///  
        /// 
        /// 
        /// 
        ///  
        public void CopyTo(TableColumn[] array, int index)
        { 
            _columnCollection.CopyTo(array, index); 
        }
 
        /// 
        ///     
        /// 
        IEnumerator IEnumerable.GetEnumerator() 
        {
            return _columnCollection.GetEnumerator(); 
        } 

        ///  
        ///     
        /// 
        IEnumerator IEnumerable.GetEnumerator()
        { 
            return ((IEnumerable)_columnCollection).GetEnumerator();
        } 
 
        /// 
        /// Appends a TableColumn to the end of the TableColumnCollection. 
        /// 
        /// The TableColumn to be added to the end of the TableColumnCollection.
        /// The TableColumnCollection index at which the TableColumn has been added.
        /// Adding a null is prohibited. 
        /// 
        /// If the item value is null. 
        ///  
        /// 
        /// If the new child already has a parent. 
        /// 
        public void Add(TableColumn item)
        {
            _columnCollection.Add(item); 
        }
 
        ///  
        /// Removes all elements from the TableColumnCollection.
        ///  
        /// 
        /// Count is set to zero. Capacity remains unchanged.
        /// To reset the capacity of the TableColumnCollection, call TrimToSize
        /// or set the Capacity property directly. 
        /// 
        public void Clear() 
        { 
            _columnCollection.Clear();
        } 

        /// 
        /// Determines whether a TableColumn is in the TableColumnCollection.
        ///  
        /// The TableColumn to locate in the TableColumnCollection.
        /// The value can be a null reference. 
        /// true if TableColumn is found in the TableColumnCollection; 
        /// otherwise, false.
        public bool Contains(TableColumn item) 
        {
            return _columnCollection.Contains(item);
        }
 
        /// 
        /// Returns the zero-based index of the TableColumn. If the TableColumn is not 
        /// in the TableColumnCollection, -1 is returned. 
        /// 
        /// The TableColumn to locate in the TableColumnCollection. 
        public int IndexOf(TableColumn item)
        {
            return _columnCollection.IndexOf(item);
        } 

        ///  
        /// Inserts a TableColumn into the TableColumnCollection at the specified index. 
        /// 
        /// The zero-based index at which value should be inserted. 
        /// The TableColumn to insert. 
        /// 
        /// indexc> is less than zero.
        /// -or- 
        /// index is greater than Count.
        ///  
        ///  
        /// If the item value is null.
        ///  
        /// 
        /// If Count already equals Capacity, the capacity of the
        /// TableColumnCollection is increased before the new TableColumn is inserted.
        /// 
        /// If index is equal to Count, TableColumn is added to the
        /// end of TableColumnCollection. 
        /// 
        /// The TableColumns that follow the insertion point move down to
        /// accommodate the new TableColumn. The indexes of the TableColumns that are 
        /// moved are also updated.
        /// 
        public void Insert(int index, TableColumn item)
        { 
            _columnCollection.Insert(index, item);
        } 
 
        /// 
        /// Removes the specified TableColumn from the TableColumnCollection. 
        /// 
        /// The TableColumn to remove from the TableColumnCollection.
        /// 
        /// If the item value is null. 
        /// 
        ///  
        /// If the specified TableColumn is not in this collection. 
        /// 
        ///  
        /// The TableColumns that follow the removed TableColumn move up to occupy
        /// the vacated spot. The indices of the TableColumns that are moved
        /// also updated.
        ///  
        public bool Remove(TableColumn item)
        { 
            return _columnCollection.Remove(item); 
        }
 
        /// 
        /// Removes the TableColumn at the specified index.
        /// 
        /// The zero-based index of the TableColumn to remove. 
        /// 
        /// index is less than zero 
        /// - or - 
        /// index is equal or greater than count.
        ///  
        /// 
        /// The TableColumns that follow the removed TableColumn move up to occupy
        /// the vacated spot. The indices of the TableColumns that are moved
        /// also updated. 
        /// 
        public void RemoveAt(int index) 
        { 
            _columnCollection.RemoveAt(index);
        } 


        /// 
        /// Removes a range of TableColumns from the TableColumnCollection. 
        /// 
        /// The zero-based index of the range 
        /// of TableColumns to remove 
        /// The number of TableColumns to remove.
        ///  
        /// index is less than zero.
        /// -or-
        /// count is less than zero.
        ///  
        /// 
        /// index and count do not denote a valid range of TableColumns in the TableColumnCollection. 
        ///  
        /// 
        /// The TableColumns that follow the removed TableColumns move up to occupy 
        /// the vacated spot. The indices of the TableColumns that are moved are
        /// also updated.
        /// 
        public void RemoveRange(int index, int count) 
        {
            _columnCollection.RemoveRange(index, count); 
        } 

        ///  
        /// Sets the capacity to the actual number of elements in the TableColumnCollection.
        /// 
        /// 
        /// This method can be used to minimize a TableColumnCollection's memory overhead 
        /// if no new elements will be added to the collection.
        /// 
        /// To completely clear all elements in a TableColumnCollection, call the Clear method 
        /// before calling TrimToSize.
        ///  
        public void TrimToSize()
        {
            _columnCollection.TrimToSize();
        } 

        #endregion Public Methods 
 
        //--------------------------------------------------------------------
        // 
        //  IList Members
        //
        //--------------------------------------------------------------------
 
        #region IList Members
 
        int IList.Add(object value) 
        {
            TableColumn item = value as TableColumn; 

            if (item == null)
            {
                throw new ArgumentException(SR.Get(SRID.TableCollectionElementTypeExpected, typeof(TableColumn).Name), "value"); 
            }
 
            return ((IList)_columnCollection).Add(value); 
        }
 
        void IList.Clear()
        {
            this.Clear();
        } 

        bool IList.Contains(object value) 
        { 
            return ((IList)_columnCollection).Contains(value);
        } 

        int IList.IndexOf(object value)
        {
            return ((IList)_columnCollection).IndexOf(value); 
        }
 
        void IList.Insert(int index, object value) 
        {
            ((IList)_columnCollection).Insert(index, value); 
        }

        bool IList.IsFixedSize
        { 
            get
            { 
                return ((IList)_columnCollection).IsFixedSize; 
            }
        } 

        bool IList.IsReadOnly
        {
            get 
            {
                return ((IList)_columnCollection).IsReadOnly; 
            } 
        }
 
        void IList.Remove(object value)
        {
            ((IList)_columnCollection).Remove(value);
        } 

        void IList.RemoveAt(int index) 
        { 
            ((IList)_columnCollection).RemoveAt(index);
        } 

        object IList.this[int index]
        {
            get 
            {
                return ((IList)_columnCollection)[index]; 
            } 

            set 
            {
                ((IList)_columnCollection)[index] = value;
            }
        } 

        #endregion IList Members 
 

        //----------------------------------------------------- 
        //
        //  Public Properties
        //
        //------------------------------------------------------ 

        #region Public Properties 
 
        /// 
        ///  
        /// 
        public int Count
        {
            get 
            {
                return _columnCollection.Count; 
            } 
        }
 
        /// 
        ///     
        ///     
        ///  
        public bool IsReadOnly  //  bool IList.IsReadOnly {get;}; bool ICollection.IsReadOnly {get;}
        { 
            get 
            {
                return _columnCollection.IsReadOnly; 
            }
        }

        ///  
        /// 
        ///  
        /// Always returns false. 
        /// 
        ///  
        public bool IsSynchronized
        {
            get
            { 
                return _columnCollection.IsSynchronized;
            } 
        } 

        ///  
        /// 
        /// 
        public object SyncRoot
        { 
            get
            { 
                return _columnCollection.SyncRoot; 
            }
        } 

        /// 
        /// Gets or sets the number of elements that the TableColumnCollection can contain.
        ///  
        /// 
        /// The number of elements that the TableColumnCollection can contain. 
        ///  
        /// 
        /// Capacity is the number of elements that the TableColumnCollection is capable of storing. 
        /// Count is the number of Visuals that are actually in the TableColumnCollection.
        ///
        /// Capacity is always greater than or equal to Count. If Count exceeds
        /// Capacity while adding elements, the capacity of the TableColumnCollection is increased. 
        ///
        /// By default the capacity is 8. 
        ///  
        /// 
        /// Capacity is set to a value that is less than Count. 
        /// 
        /// 
        public int Capacity
        { 
            get
            { 
                return _columnCollection.PrivateCapacity; 
            }
            set 
            {
                _columnCollection.PrivateCapacity = value;
            }
        } 

        ///  
        /// Indexer for the TableColumnCollection. Gets the TableColumn stored at the 
        /// zero-based index of the TableColumnCollection.
        ///  
        /// This property provides the ability to access a specific TableColumn in the
        /// TableColumnCollection by using the following systax: TableColumn myTableColumn = myTableColumnCollection[index].
        /// 
        ///  
        /// index is less than zero -or- index is equal to or greater than Count.
        ///  
        public TableColumn this[int index] 
        {
            get 
            {
                return _columnCollection[index];
            }
            set 
            {
                _columnCollection[index] = value; 
            } 
        }
 
        #endregion Public Properties


        private TableColumnCollectionInternal _columnCollection; 
    }
 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK