// Copyright (C) Stichting Deltares 2016. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using System.Collections.Generic;
namespace Core.Components.Charting.Data
{
///
/// This class represents a collection of .
///
public class ChartDataCollection : ChartData
{
///
/// Creates a new instance of .
///
/// A of .
/// The name of the .
/// Thrown when is null.
/// Thrown when is
/// null or only whitespace.
public ChartDataCollection(IList list, string name) : base(name)
{
if (list == null)
{
throw new ArgumentNullException("list", "A list collection is required when creating ChartDataCollection.");
}
List = list;
}
///
/// Gets the list of of the .
///
public IList List { get; private set; }
///
/// Adds an element to the list of .
///
/// The element to add to the list.
/// Thrown when is null.
public void Add(ChartData elementToAdd)
{
if (elementToAdd == null)
{
throw new ArgumentNullException("elementToAdd", "An element cannot be null when adding it to the collection.");
}
List.Add(elementToAdd);
}
///
/// Replaces an element in the list of .
///
/// The element to replace.
/// The element to replace with.
/// Thrown when or
/// is null.
public void Replace(ChartData oldElement, ChartData newElement)
{
if (newElement == null)
{
throw new ArgumentNullException("newElement", "An element cannot be replaced with null. Use Remove instead.");
}
if (oldElement == null)
{
throw new ArgumentNullException("oldElement", "A null element cannot be replaced. User Add instead.");
}
for (var i = 0; i < List.Count; i++)
{
if (List[i].Equals(oldElement))
{
List[i] = newElement;
}
}
}
///
/// Removes the given element from the list of .
///
/// The element to remove.
public void Remove(ChartData elementToRemove)
{
List.Remove(elementToRemove);
}
}
}