From c6aa05d35df4e6f4c4d163ca5cf0520e2f8499f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Fri, 17 Jun 2011 06:43:37 +0200 Subject: [PATCH] Addded GetSubTypeDefinitions method. That's like a routine we had in the old MD dom - it's used for example for finding all exceptions in an assembly. --- .../TypeSystem/ExtensionMethods.cs | 15 ++++++++++++++- ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs b/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs index 1bb0210dd3..e746c401c4 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs @@ -252,6 +252,19 @@ namespace ICSharpCode.NRefactory.TypeSystem .Concat (type.GetMethods (context, filter).SafeCast ()) .Concat (type.GetEvents (context, filter).SafeCast ()); } - #endregion + #endregion + + #region GetSubTypeDefinitions + /// + /// Gets all sub type definitions defined in a context. + /// + public static IEnumerable GetSubTypeDefinitions (this IType baseType, ITypeResolveContext context) + { + foreach (var contextType in context.GetAllClasses ()) { + if (contextType.IsDerivedFrom (baseType, context)) + yield return contextType; + } + } + #endregion } } diff --git a/ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs b/ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs index e396a23d17..e6552b79bf 100644 --- a/ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs +++ b/ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs @@ -9,7 +9,7 @@ using System.Threading; namespace ICSharpCode.NRefactory { /// - /// Provides an interface to handle annotations in an objectj + /// Provides an interface to handle annotations in an object. /// public interface IAnnotatable {