public static IEnumerable <DataItem> Find(this DataItemCollection c, Func <DataItem, bool> criteria) { List <DataItem> itemList = new List <DataItem>(); // look in the collection var items = from i in c.Items where criteria(i) select i; if (items != null) { itemList.AddRange(items); } // look in subcomponents foreach (var subcomponent in c.Parent.Components) { items = subcomponent.DataItems.Find(criteria); if (items != null) { itemList.AddRange(items); } } if (itemList.Count == 0) { return(null); } return(itemList); }
internal DataItemCollection(DataItemCollection collection) { foreach (var di in collection) { this.Add(new DataItem(di)); } m_parent = collection.Parent; }
internal ComponentBase() { Components = new ComponentCollection(); Properties = new PropertyCollection(); DataItems = new DataItemCollection(this); Components.DataItemValueSet += new EventHandler <DataItemValue>(DataItems_DataItemValueSet); DataItems.DataItemValueSet += new EventHandler <DataItemValue>(DataItems_DataItemValueSet); }