using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.IO;
using FastReport.Utils;
namespace FastReport
{
///
/// Represents a collection of sort conditions used in the .
///
public class SortCollection : CollectionBase, IFRSerializable
{
///
/// Gets or sets the element at the specified index.
///
/// Index of an element.
/// The element at the specified index.
public Sort this[int index]
{
get { return List[index] as Sort; }
set { List[index] = value; }
}
///
/// Adds the specified elements to the end of this collection.
///
///
public void AddRange(Sort[] range)
{
foreach (Sort s in range)
{
Add(s);
}
}
///
/// Adds an object to the end of this collection.
///
/// Object to add.
/// Index of the added object.
public int Add(Sort value)
{
return List.Add(value);
}
///
/// Inserts an object into this collection at the specified index.
///
/// The zero-based index at which value should be inserted.
/// The object to insert.
public void Insert(int index, Sort value)
{
List.Insert(index, value);
}
///
/// Removes the specified object from the collection.
///
/// Object to remove.
public void Remove(Sort value)
{
int i = IndexOf(value);
if (i != -1)
List.RemoveAt(i);
}
///
/// Returns the zero-based index of the first occurrence of an object.
///
/// The object to locate in the collection.
/// The zero-based index of the first occurrence of value within the entire collection, if found;
/// otherwise, -1.
public int IndexOf(Sort value)
{
return List.IndexOf(value);
}
///
/// Determines whether an element is in the collection.
///
/// The object to locate in the collection.
/// true if object is found in the collection; otherwise, false.
public bool Contains(Sort value)
{
return IndexOf(value) != -1;
}
///
public void Serialize(FRWriter writer)
{
writer.ItemName = "Sort";
foreach (Sort s in this)
{
writer.Write(s);
}
}
///
public void Deserialize(FRReader reader)
{
Clear();
while (reader.NextItem())
{
Sort s = new Sort();
reader.Read(s);
Add(s);
}
}
///
/// Assigns values from another collection.
///
/// Collection to assign from.
public void Assign(SortCollection source)
{
Clear();
foreach (Sort sort in source)
{
Add(sort);
}
}
}
}