// NAnt - A .NET build tool
// Copyright (C) 2001-2003 Gerry Shaw
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Gert Driesen (gert.driesen@ardatis.com)
using System;
using System.Collections;
namespace NAnt.NUnit.Types {
///
/// Contains a strongly typed collection of objects.
///
[Serializable]
public class FormatterElementCollection : CollectionBase {
#region Public Instance Constructors
///
/// Initializes a new instance of the class.
///
public FormatterElementCollection() {
}
///
/// Initializes a new instance of the class
/// with the specified instance.
///
public FormatterElementCollection(FormatterElementCollection value) {
AddRange(value);
}
///
/// Initializes a new instance of the class
/// with the specified array of instances.
///
public FormatterElementCollection(FormatterElement[] value) {
AddRange(value);
}
#endregion Public Instance Constructors
#region Public Instance Properties
///
/// Gets or sets the element at the specified index.
///
/// The zero-based index of the element to get or set.
[System.Runtime.CompilerServices.IndexerName("Item")]
public FormatterElement this[int index] {
get {return ((FormatterElement)(base.List[index]));}
set {base.List[index] = value;}
}
#endregion Public Instance Properties
#region Public Instance Methods
///
/// Adds a to the end of the collection.
///
/// The to be added to the end of the collection.
/// The position into which the new element was inserted.
public int Add(FormatterElement item) {
return base.List.Add(item);
}
///
/// Adds the elements of a array to the end of the collection.
///
/// The array of elements to be added to the end of the collection.
public void AddRange(FormatterElement[] items) {
for (int i = 0; (i < items.Length); i = (i + 1)) {
Add(items[i]);
}
}
///
/// Adds the elements of a to the end of the collection.
///
/// The to be added to the end of the collection.
public void AddRange(FormatterElementCollection items) {
for (int i = 0; (i < items.Count); i = (i + 1)) {
Add(items[i]);
}
}
///
/// Determines whether a is in the collection.
///
/// The to locate in the collection.
///
/// if is found in the
/// collection; otherwise, .
///
public bool Contains(FormatterElement item) {
return base.List.Contains(item);
}
///
/// Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.
///
/// The one-dimensional array that is the destination of the elements copied from the collection. The array must have zero-based indexing.
/// The zero-based index in at which copying begins.
public void CopyTo(FormatterElement[] array, int index) {
base.List.CopyTo(array, index);
}
///
/// Retrieves the index of a specified object in the collection.
///
/// The object for which the index is returned.
///
/// The index of the specified . If the is not currently a member of the collection, it returns -1.
///
public int IndexOf(FormatterElement item) {
return base.List.IndexOf(item);
}
///
/// Inserts a into the collection at the specified index.
///
/// The zero-based index at which should be inserted.
/// The to insert.
public void Insert(int index, FormatterElement item) {
base.List.Insert(index, item);
}
///
/// Returns an enumerator that can iterate through the collection.
///
///
/// A for the entire collection.
///
public new FormatterElementEnumerator GetEnumerator() {
return new FormatterElementEnumerator(this);
}
///
/// Removes a member from the collection.
///
/// The to remove from the collection.
public void Remove(FormatterElement item) {
base.List.Remove(item);
}
#endregion Public Instance Methods
}
///
/// Enumerates the elements of a .
///
public class FormatterElementEnumerator : IEnumerator {
#region Internal Instance Constructors
///
/// Initializes a new instance of the class
/// with the specified .
///
/// The collection that should be enumerated.
internal FormatterElementEnumerator(FormatterElementCollection arguments) {
IEnumerable temp = (IEnumerable) (arguments);
_baseEnumerator = temp.GetEnumerator();
}
#endregion Internal Instance Constructors
#region Implementation of IEnumerator
///
/// Gets the current element in the collection.
///
///
/// The current element in the collection.
///
public FormatterElement Current {
get { return (FormatterElement) _baseEnumerator.Current; }
}
object IEnumerator.Current {
get { return _baseEnumerator.Current; }
}
///
/// Advances the enumerator to the next element of the collection.
///
///
/// if the enumerator was successfully advanced
/// to the next element; if the enumerator has
/// passed the end of the collection.
///
public bool MoveNext() {
return _baseEnumerator.MoveNext();
}
bool IEnumerator.MoveNext() {
return _baseEnumerator.MoveNext();
}
///
/// Sets the enumerator to its initial position, which is before the
/// first element in the collection.
///
public void Reset() {
_baseEnumerator.Reset();
}
void IEnumerator.Reset() {
_baseEnumerator.Reset();
}
#endregion Implementation of IEnumerator
#region Private Instance Fields
private IEnumerator _baseEnumerator;
#endregion Private Instance Fields
}
}