diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2014-01-20 19:32:53 +0400 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@xamarin.com> | 2014-10-21 18:39:14 +0400 |
commit | f73b2a9990495587d514aa1856919c21170a3940 (patch) | |
tree | 9842411ee8644ead5915a715ee7e53984a601df4 /main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ItemTypeCondition.cs | |
parent | a2046b6331a271e8203df7d3d0f14500d33d60fa (diff) |
Initial drop of the new project model
Diffstat (limited to 'main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ItemTypeCondition.cs')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ItemTypeCondition.cs | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ItemTypeCondition.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ItemTypeCondition.cs index 48824db647..5bd95f10eb 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ItemTypeCondition.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ItemTypeCondition.cs @@ -34,7 +34,7 @@ namespace MonoDevelop.Projects.Extensions public class ItemTypeCondition: ConditionType { Type objType; - List<string> typeNames; + HashSet<string> typeNames; IDictionary<string,string> aliases; public ItemTypeCondition () @@ -87,7 +87,7 @@ namespace MonoDevelop.Projects.Extensions aliases [alias] = fullName; } - bool MatchesType (string type) + protected bool MatchesType (string type) { if (type.IndexOf ('.') == -1) { string res; @@ -106,29 +106,36 @@ namespace MonoDevelop.Projects.Extensions // use of the condition. if (typeNames == null) { - typeNames = new List<string> (); - - typeNames.Add (objType.FullName); - typeNames.Add (objType.AssemblyQualifiedName); + typeNames = new HashSet<string> (); + + foreach (var t in GetObjectTypes ()) { + typeNames.Add (t.FullName); + typeNames.Add (t.AssemblyQualifiedName); - // base class hierarchy + // base class hierarchy - Type baseType = objType.BaseType; - while (baseType != null) { - typeNames.Add (baseType.FullName); - typeNames.Add (baseType.AssemblyQualifiedName); - baseType = baseType.BaseType; - } + Type baseType = t.BaseType; + while (baseType != null) { + typeNames.Add (baseType.FullName); + typeNames.Add (baseType.AssemblyQualifiedName); + baseType = baseType.BaseType; + } - // Implemented interfaces + // Implemented interfaces - Type[] interfaces = objType.GetInterfaces(); - foreach (Type itype in interfaces) { - typeNames.Add (itype.FullName); - typeNames.Add (itype.AssemblyQualifiedName); + Type[] interfaces = t.GetInterfaces (); + foreach (Type itype in interfaces) { + typeNames.Add (itype.FullName); + typeNames.Add (itype.AssemblyQualifiedName); + } } } return typeNames.Contains (type); } + + protected virtual IEnumerable<Type> GetObjectTypes () + { + yield return objType; + } } } |