using System; using System.Collections.Generic; namespace BismNormalizer.TabularCompare.TabularMetadata { /// /// Represents a collection of Measure objects. /// public class MeasureCollection : List { /// /// Find an object in the collection by name. /// /// /// Measure object if found. Null if not found. public Measure FindByName(string name) { foreach (Measure measure in this) { if (measure.Name == name) { return measure; } } 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 (Measure measure in this) { if (measure.Name == name) { return true; } } return false; } /// /// A Boolean specifying whether the collection contains object by name searching without case sensitivity. /// /// /// True if the object is found, or False if it's not found. public bool ContainsNameCaseInsensitive(string name) { foreach (Measure measure in this) { if (measure.Name.ToUpper() == name.ToUpper()) { return true; } } return false; } /// /// Returns a collection of Measure objects filtered by the parent table's name. /// /// /// MeasureCollection public MeasureCollection FilterByTableName(string tableName) { MeasureCollection returnMeasures = new MeasureCollection(); foreach (Measure measure in this) { if (measure.TableName == tableName) { returnMeasures.Add(measure); } } return returnMeasures; } /// /// Removes an object from the collection by its name. /// /// /// True if the object was removed, or False if was not found. public bool RemoveByName(string name) { foreach (Measure measure in this) { if (measure.Name == name) { this.Remove(measure); return true; } } return false; } } }