using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BismNormalizer.TabularCompare.MultidimensionalMetadata
{
///
/// Represents a collection of Kpi objects.
///
public class KpiCollection : List
{
///
/// Find an object in the collection by Id.
///
///
/// Kpi object if found. Null if not found.
public Kpi FindById(string id)
{
foreach (Kpi kpi in this)
{
if (kpi.Id == id)
{
return kpi;
}
}
return null;
}
///
/// A Boolean specifying whether the collection contains object by Id.
///
///
/// True if the object is found, or False if it's not found.
public bool ContainsId(string id)
{
foreach (Kpi kpi in this)
{
if (kpi.Id == id)
{
return true;
}
}
return false;
}
///
/// Find an object in the collection by name.
///
///
/// Kpi object if found. Null if not found.
public Kpi FindByName(string name)
{
foreach (Kpi kpi in this)
{
if (kpi.Name == name)
{
return kpi;
}
}
return null;
}
///
/// A Boolean specifying whether the collection contains object by name.
///
///
/// True if the object is found, or False if it's not found.
public bool ContainsName(string name)
{
foreach (Kpi BismKpi in this)
{
if (BismKpi.Name == name)
{
return true;
}
}
return false;
}
///
/// Returns a collection of Kpi objects filtered by the parent table's name.
///
///
/// KpiCollection
public KpiCollection FilterByTableName(string tableName)
{
KpiCollection returnMeasures = new KpiCollection();
foreach (Kpi kpi in this)
{
if (kpi.TableName == tableName)
{
returnMeasures.Add(kpi);
}
}
return returnMeasures;
}
///
/// Removes an object from the collection by its Id.
///
///
/// True if the object was removed, or False if was not found.
public bool RemoveById(string id)
{
foreach (Kpi kpi in this)
{
if (kpi.Id == id)
{
this.Remove(kpi);
return true;
}
}
return false;
}
}
}