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