/*
* Namespace Summary
* Copyright (C) 2005+ Bogdan Damian Constantin
* E-Mail: damianbcpetro@gmail.com
* WEB: http://www.sourceforge.net/projects/dataholder
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License 2.1 or later, as
* published by the Free Software Foundation. See the included License.txt
* or http://www.gnu.org/copyleft/lesser.html for details.
*
*/
using System;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using DataHolder.Containers.Property;
namespace DataHolder.Containers{
public class GenericDataCollectionView<GD> : BaseGenericDataCollectionView where GD:GenericData
{
private GenericDataCollection<GD> typedInnerCollection = null;
#region constructors
public GenericDataCollectionView(GenericDataCollection<GD> gecoll):base(gecoll)
{
typedInnerCollection = gecoll;
}
public GenericDataCollectionView(GenericDataCollection<GD> gecoll, bool allow_new, bool allow_remove, bool allow_edit)
: this(gecoll)
{
l_AllowNew = allow_new;
lAllowRemove = allow_remove;
lAllowEdit = allow_edit;
}
#endregion
/// <summary>
/// Collection that is viewed trough this view
/// </summary>
public GenericDataCollection<GD> SourceCollection
{
get
{
return typedInnerCollection;
}
}
public GD this[int index]
{
get
{
return typedInnerCollection[Positions[index]];
}
set
{
typedInnerCollection[Positions[index]] = value;
}
}
public void Insert(int index, GD value)
{
typedInnerCollection.Insert(Positions[index], value);
}
public void Remove(GD value)
{
typedInnerCollection.Remove(value);
}
public bool Contains(GD value)
{
return typedInnerCollection.Contains(value);
}
public int IndexOf(GD value)
{
for(int i = 0; i < Positions.Length; i++)
if (value == typedInnerCollection.GetObjectAt(Positions[i]))
return i;
return -1;
}
public void Add(GD value)
{
typedInnerCollection.Add(value);
}
public void CopyTo(GD[] array, int index)
{
typedInnerCollection.CopyTo(array, index);
}
}
}
|