using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; namespace BismNormalizer.TabularCompare.MultidimensionalMetadata { /// /// Represents a collection of DataSource objects. /// public class TableCollection : List { /// /// Find an object in the collection by name. /// /// /// DataSource object if found. Null if not found. public Table FindByName(string name) { foreach (Table table in this) { if (table.Name == name) { return table; } } 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 (Table table in this) { if (table.Name == name) { return true; } } return false; } /// /// Find an object in the collection by Id. /// /// /// DataSource object if found. Null if not found. public Table FindById(string id) { foreach (Table table in this) { if (table.Id == id) { return table; } } 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 (Table table in this) { if (table.Id == id) { return true; } } return false; } /// /// Returns a collection of Table objects filtered by the parent datasource's Id. /// /// /// TableCollection public TableCollection FilterByDataSourceId(string dataSourceId) { TableCollection returnTables = new TableCollection(); foreach (Table table in this) { if (table.DataSourceID == dataSourceId) { returnTables.Add(table); } } return returnTables; } /// /// 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 (Table table in this) { if (table.Id == id) { this.Remove(table); return true; } } return false; } } }