using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using FastReport.Utils;
namespace FastReport.CrossView
{
///
/// Represents a collection of CrossView header descriptors used in the .
///
public class CrossViewHeader : CollectionBase, IFRSerializable
{
private string name;
///
/// Gets or sets the element at the specified index.
///
/// Index of an element.
/// The element at the specified index.
public CrossViewHeaderDescriptor this[int index]
{
get { return List[index] as CrossViewHeaderDescriptor; }
set { List[index] = value; }
}
internal string Name
{
get { return name; }
set { name = value; }
}
///
/// Adds the specified descriptors to the end of this collection.
///
/// Array of descriptors to add.
internal void AddRange(CrossViewHeaderDescriptor[] range)
{
foreach (CrossViewHeaderDescriptor s in range)
{
Add(s);
}
}
///
/// Adds a descriptor to the end of this collection.
///
/// Descriptor to add.
/// Index of the added descriptor.
internal int Add(CrossViewHeaderDescriptor value)
{
return List.Add(value);
}
///
/// Inserts a descriptor into this collection at the specified index.
///
/// The zero-based index at which value should be inserted.
/// The descriptor to insert.
internal void Insert(int index, CrossViewHeaderDescriptor value)
{
List.Insert(index, value);
}
///
/// Removes the specified descriptor from the collection.
///
/// Descriptor to remove.
internal void Remove(CrossViewHeaderDescriptor value)
{
int i = IndexOf(value);
if (i != -1)
List.RemoveAt(i);
}
///
/// Returns the zero-based index of the first occurrence of a descriptor.
///
/// The descriptor to locate in the collection.
/// The zero-based index of the first occurrence of descriptor within
/// the entire collection, if found; otherwise, -1.
internal int IndexOf(CrossViewHeaderDescriptor value)
{
return List.IndexOf(value);
}
///
/// Determines whether a descriptor is in the collection.
///
/// The descriptor to locate in the collection.
/// true if descriptor is found in the collection; otherwise, false.
internal bool Contains(CrossViewHeaderDescriptor value)
{
return List.Contains(value);
}
///
/// Copies the elements of this collection to a new array.
///
/// An array containing copies of this collection elements.
internal CrossViewHeaderDescriptor[] ToArray()
{
CrossViewHeaderDescriptor[] result = new CrossViewHeaderDescriptor[Count];
for (int i = 0; i < Count; i++)
{
result[i] = this[i];
}
return result;
}
///
public void Serialize(FRWriter writer)
{
writer.ItemName = Name;
foreach (CrossViewHeaderDescriptor d in this)
{
writer.Write(d);
}
}
///
public void Deserialize(FRReader reader)
{
Clear();
while (reader.NextItem())
{
CrossViewHeaderDescriptor d = new CrossViewHeaderDescriptor();
reader.Read(d);
Add(d);
}
}
///
///
///
public CrossViewHeader()
{
}
}
}