コード例 #1
0
        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);
        }
コード例 #2
0
 internal DataItemCollection(DataItemCollection collection)
 {
     foreach (var di in collection)
     {
         this.Add(new DataItem(di));
     }
     m_parent = collection.Parent;
 }
コード例 #3
0
ファイル: ComponentBase.cs プロジェクト: ctacke/mtconnect
        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);
        }