// ---------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------
//
//
// ---------------------------------------------------------------------
namespace Microsoft.Database.Isam
{
using System;
using System.Collections;
///
/// A class used by to represent which
/// columns are used by a particular index.
///
public class KeyColumnCollection : CollectionBase
{
///
/// The read only
///
private bool readOnly = false;
///
/// Gets or sets a value indicating whether the collection is Read-Only.
///
///
/// true if [read only]; otherwise, false.
///
public bool ReadOnly
{
get
{
return this.readOnly;
}
set
{
this.CheckReadOnly();
this.readOnly = value;
}
}
///
/// Gets or sets the element at the specified index.
///
/// The index.
/// The element at the specified index.
public KeyColumn this[int index]
{
get
{
return (KeyColumn)this.List[index];
}
set
{
this.CheckReadOnly();
this.List[index] = value;
}
}
///
/// Adds the specified key column.
///
/// The key column.
public void Add(KeyColumn keyColumn)
{
List.Add(keyColumn);
}
///
/// Gets the index of the specified .
///
/// The key column.
/// An index to be used.
public int IndexOf(KeyColumn keyColumn)
{
return List.IndexOf(keyColumn);
}
///
/// Inserts the specified index.
///
/// The index.
/// The key column.
public void Insert(int index, KeyColumn keyColumn)
{
List.Insert(index, keyColumn);
}
///
/// Removes the specified key column.
///
/// The key column.
public void Remove(KeyColumn keyColumn)
{
List.Remove(keyColumn);
}
///
/// Determines whether the specified is present in this collection.
///
/// The key column.
/// Whether the specified is present in this collection.
public bool Contains(KeyColumn keyColumn)
{
return List.Contains(keyColumn);
}
///
/// Performs additional custom processes when clearing the contents of the instance.
///
protected override void OnClear()
{
this.CheckReadOnly();
}
///
/// Performs additional custom processes before inserting a new element into the instance.
///
/// The zero-based index at which to insert .
/// The new value of the element at .
protected override void OnInsert(int index, object value)
{
this.CheckReadOnly();
}
///
/// Performs additional custom processes when removing an element from the instance.
///
/// The zero-based index at which can be found.
/// The value of the element to remove from .
protected override void OnRemove(int index, object value)
{
this.CheckReadOnly();
}
///
/// Performs additional custom processes before setting a value in the instance.
///
/// The zero-based index at which can be found.
/// The value to replace with .
/// The new value of the element at .
protected override void OnSet(int index, object oldValue, object newValue)
{
this.CheckReadOnly();
}
///
/// Performs additional custom processes when validating a value.
///
/// The object to validate.
/// value must be of type KeyColumn;value
protected override void OnValidate(object value)
{
if (!(value is KeyColumn))
{
throw new ArgumentException("value must be of type KeyColumn", "value");
}
}
///
/// Checks the read only.
///
/// this key column collection cannot be changed
private void CheckReadOnly()
{
if (this.ReadOnly)
{
throw new NotSupportedException("this key column collection cannot be changed");
}
}
}
}