use extension method OfType<T> defined in MBS.Framework.Collections.Generic

This commit is contained in:
Michael Becker 2020-11-20 22:16:53 -05:00
parent e2021ee52e
commit 9c7399461d
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7

View File

@ -22,6 +22,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MBS.Framework.Collections.Generic;
namespace UniversalEditor.ObjectModels.PropertyList
{
public abstract class PropertyListItem : ICloneable
@ -48,12 +50,14 @@ namespace UniversalEditor.ObjectModels.PropertyList
}
}
private Dictionary<Type, System.Collections.IList> cacheOfT = new Dictionary<Type, System.Collections.IList>();
public T OfType<T>(string name) where T : PropertyListItem
{
for (int i = 0; i < Count; i++)
T[] items = this.OfType<T>();
for (int i = 0; i < items.Length; i++)
{
if (this[i].Name == name && this[i] is T)
return (T)this[i];
if (items[i].Name == name)
return items[i];
}
return null;
}