#region Disclaimer / License
// Copyright (C) 2013, Jackie Ng
// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@gmail.com
//
// Original code from SharpDevelop 3.2.1 licensed under the same terms (LGPL 2.1)
// Copyright 2002-2010 by
//
// AlphaSierraPapa, Christoph Wille
// Vordernberger Strasse 27/8
// A-8700 Leoben
// Austria
//
// email: office@alphasierrapapa.com
// court of jurisdiction: Landesgericht Leoben
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion Disclaimer / License
using System;
using System.Collections;
namespace Maestro.Editors.Generic.XmlEditor.AutoCompletion
{
///
/// A collection that stores objects.
///
[Serializable]
internal class QualifiedNameCollection : CollectionBase
{
///
/// Initializes a new instance of .
///
public QualifiedNameCollection()
{
}
///
/// Initializes a new instance of based on another .
///
///
/// A from which the contents are copied
///
public QualifiedNameCollection(QualifiedNameCollection val)
{
this.AddRange(val);
}
///
/// Initializes a new instance of containing any array of objects.
///
///
/// A array of objects with which to intialize the collection
///
public QualifiedNameCollection(QualifiedName[] val)
{
this.AddRange(val);
}
///
/// Represents the entry at the specified index of the .
///
/// The zero-based index of the entry to locate in the collection.
/// The entry at the specified index of the collection.
/// is outside the valid range of indexes for the collection.
public QualifiedName this[int index]
{
get
{
return ((QualifiedName)(List[index]));
}
set
{
List[index] = value;
}
}
///
/// Adds a with the specified value to the
/// .
///
/// The to add.
/// The index at which the new element was inserted.
public int Add(QualifiedName val)
{
return List.Add(val);
}
///
/// Copies the elements of an array to the end of the .
///
///
/// An array of type containing the objects to add to the collection.
///
///
public void AddRange(QualifiedName[] val)
{
for (int i = 0; i < val.Length; i++)
{
this.Add(val[i]);
}
}
///
/// Adds the contents of another to the end of the collection.
///
///
/// A containing the objects to add to the collection.
///
///
public void AddRange(QualifiedNameCollection val)
{
for (int i = 0; i < val.Count; i++)
{
this.Add(val[i]);
}
}
///
/// Gets a value indicating whether the
/// contains the specified .
///
/// The to locate.
///
/// if the is contained in the collection;
/// otherwise, .
///
///
public bool Contains(QualifiedName val)
{
return List.Contains(val);
}
///
/// Copies the values to a one-dimensional instance at the
/// specified index.
///
/// The one-dimensional that is the destination of the values copied from .
/// The index in where copying begins.
///
/// is multidimensional.
/// -or-
/// The number of elements in the is greater than
/// the available space between and the end of
/// .
///
/// is .
/// is less than 's lowbound.
///
public void CopyTo(QualifiedName[] array, int index)
{
List.CopyTo(array, index);
}
///
/// Returns the index of a in
/// the .
///
/// The to locate.
///
/// The index of the of in the
/// , if found; otherwise, -1.
///
///
public int IndexOf(QualifiedName val)
{
return List.IndexOf(val);
}
///
/// Inserts a into the at the specified index.
///
/// The zero-based index where should be inserted.
/// The to insert.
///
public void Insert(int index, QualifiedName val)
{
List.Insert(index, val);
}
///
/// Returns an enumerator that can iterate through the .
///
///
public new QualifiedNameEnumerator GetEnumerator()
{
return new QualifiedNameEnumerator(this);
}
///
/// Removes a specific from the .
///
/// The to remove from the .
/// is not found in the Collection.
public void Remove(QualifiedName val)
{
List.Remove(val);
}
///
/// Removes the last item in this collection.
///
public void RemoveLast()
{
if (Count > 0)
{
RemoveAt(Count - 1);
}
}
///
/// Removes the first item in the collection.
///
public void RemoveFirst()
{
if (Count > 0)
{
RemoveAt(0);
}
}
///
/// Gets the namespace prefix of the last item.
///
public string LastPrefix
{
get
{
if (Count > 0)
{
QualifiedName name = this[Count - 1];
return name.Prefix;
}
return String.Empty;
}
}
///
/// Enumerator that can iterate through a QualifiedNameCollection.
///
///
///
///
public class QualifiedNameEnumerator : IEnumerator
{
private readonly IEnumerator baseEnumerator;
private IEnumerable temp;
///
/// Initializes a new instance of .
///
public QualifiedNameEnumerator(QualifiedNameCollection mappings)
{
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator();
}
///
/// Gets the current in the .
///
public QualifiedName Current
{
get
{
return ((QualifiedName)(baseEnumerator.Current));
}
}
object IEnumerator.Current
{
get
{
return baseEnumerator.Current;
}
}
///
/// Advances the enumerator to the next of the .
///
public bool MoveNext()
{
return baseEnumerator.MoveNext();
}
///
/// Sets the enumerator to its initial position, which is before the first element in the .
///
public void Reset()
{
baseEnumerator.Reset();
}
}
}
}