/*
* Mentalis.org Security Library
*
* Copyright © 2002-2005, The KPD-Team
* All rights reserved.
* http://www.mentalis.org/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of the KPD-Team, nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Specialized;
namespace Org.Mentalis.Security.Certificates {
///
/// Implements a collection of instances.
///
public class DistinguishedNameList : IEnumerable,ICloneable {
///
/// Initializes a new instance.
///
public DistinguishedNameList() {
m_List = new ArrayList();
}
///
/// Initializes a new instance.
///
/// The initial state of the collection.
/// is a null reference (Nothing in Visual Basic).
internal DistinguishedNameList(ArrayList state) {
if (state == null)
throw new ArgumentNullException();
m_List = (ArrayList)state.Clone();
}
///
/// Gets a value indicating whether the has a fixed size.
///
/// true if the ArrayList has a fixed size; otherwise, false.
public bool IsFixedSize {
get {
return m_List.IsFixedSize;
}
}
///
/// Gets a value indicating whether the is read-only.
///
/// true if the ArrayList is read-only; otherwise, false.
public bool IsReadOnly {
get {
return m_List.IsReadOnly;
}
}
///
/// Gets or sets the element at the specified index.
///
/// The zero-based index of the element to get or set.
/// The element at the specified index.
/// is a null reference (Nothing in Visual Basic).
/// is less than zero -or- is equal to or greater than .
public DistinguishedName this[int index] {
get {
return (DistinguishedName)m_List[index];
}
set{
if (value == null)
throw new ArgumentNullException();
m_List[index] = value;
}
}
///
/// Adds a to the end of the .
///
/// The to be added to the end of the DistinguishedNameList.
/// The list index at which the value has been added.
/// is a null reference (Nothing in Visual Basic).
/// The list is read-only -or- the list has a fixed size.
public int Add(DistinguishedName value) {
if (value == null)
throw new ArgumentNullException();
return m_List.Add(value);
}
///
/// Removes all elements from the .
///
/// The list is read-only -or- the list has a fixed size.
public void Clear() {
m_List.Clear();
}
///
/// Determines whether an element is in the .
///
/// The Object to locate in the DistinguishedNameList. The element to locate cannot be a null reference (Nothing in Visual Basic).
/// true if item is found in the DistinguishedNameList; otherwise, false.
/// is a null reference (Nothing in Visual Basic).
public bool Contains(DistinguishedName value) {
if (value == null)
throw new ArgumentNullException();
return m_List.Contains(value);
}
///
/// Searches for the specified and returns the zero-based index of the first occurrence within the entire .
///
/// The DistinguishedName to locate in the DistinguishedNameList.
/// The zero-based index of the first occurrence of value within the entire DistinguishedNameList, if found; otherwise, -1.
/// is a null reference (Nothing in Visual Basic).
public int IndexOf(DistinguishedName value) {
if (value == null)
throw new ArgumentNullException();
return m_List.IndexOf(value);
}
///
/// Inserts an element into the at the specified index.
///
/// The zero-based index at which should be inserted.
/// The to insert.
/// is a null reference (Nothing in Visual Basic).
/// is less than zero -or- is greater than .
/// The DistinguishedNameList is read-only -or- the DistinguishedNameList has a fixed size.
public void Insert(int index, DistinguishedName value) {
if (value == null)
throw new ArgumentNullException();
m_List.Insert(index, value);
}
///
/// Removes the first occurrence of a specific object from the .
///
/// The to remove from the DistinguishedNameList.
/// is a null reference (Nothing in Visual Basic).
/// The DistinguishedNameList is read-only -or- the DistinguishedNameList has a fixed size.
public void Remove(DistinguishedName value) {
m_List.Remove(value);
}
///
/// Removes the element at the specified index of the .
///
/// The zero-based index of the element to remove.
/// is less than zero -or- is greater than .
/// The DistinguishedNameList is read-only -or- the DistinguishedNameList has a fixed size.
public void RemoveAt(int index) {
m_List.RemoveAt(index);
}
///
/// Gets the number of elements actually contained in the .
///
/// The number of elements actually contained in the DistinguishedNameList.
public int Count {
get {
return m_List.Count;
}
}
///
/// Gets a value indicating whether access to the is synchronized (thread-safe).
///
/// true if access to the DistinguishedNameList is synchronized (thread-safe); otherwise, false.
public bool IsSynchronized {
get {
return m_List.IsSynchronized;
}
}
///
/// Gets an object that can be used to synchronize access to the .
///
/// An object that can be used to synchronize access to the DistinguishedNameList.
public object SyncRoot {
get {
return m_List.SyncRoot;
}
}
///
/// Copies the entire to a compatible one-dimensional , starting at the specified index of the target array.
///
/// The one-dimensional Array that is the destination of the elements copied from DistinguishedNameList. The Array must have zero-based indexing.
/// The zero-based index in at which copying begins.
/// is a null reference (Nothing in Visual Basic).
/// is less than zero.
/// is multidimensional -or- is equal to or greater than the length of -or- the number of elements in the source DistinguishedNameList is greater than the available space from to the end of the destination array.
/// The type of the source DistinguishedNameList cannot be cast automatically to the type of the destination array.
public void CopyTo(Array array, int index) {
m_List.CopyTo(array, index);
}
///
/// Returns an enumerator for the entire .
///
/// An IEnumerator for the entire ArrayList.
public IEnumerator GetEnumerator() {
return m_List.GetEnumerator();
}
///
/// Creates a shallow copy of the .
///
/// A shallow copy of the DistinguishedNameList.
public object Clone() {
return new DistinguishedNameList(m_List);
}
///
/// Holds the internal list.
///
private ArrayList m_List;
}
}