using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; namespace BismNormalizer.TabularCompare.TabularMetadata { /// /// 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; } /// /// Find an object in the collection by internal name. /// /// /// Relationship object if found. Null if not found. public Relationship FindByInternalName(string internalName) { foreach (Relationship relationship in this) { if (relationship.InternalName == internalName) { 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.Trim()) { return true; } } return false; } /// /// A Boolean specifying whether the collection contains object by internal name. /// /// /// True if the object is found, or False if it's not found. public bool ContainsInternalName(string internalName) { foreach (Relationship relationship in this) { if (relationship.InternalName == internalName) { return true; } } return false; } /// /// Removes an object from the collection by its internal name. /// /// /// True if the object was removed, or False if was not found. public bool RemoveByInternalName(string internalName) { foreach (Relationship relationship in this) { if (relationship.InternalName == internalName) { this.Remove(relationship); return true; } } return false; } } }