Добавить комментарий - CodeHelper

Добавить комментарий

В общем, такой поиск может выглядеть так:

public static class ExtensionMethods
{
    private static void GetAllInstancesRecursive(IApplicationContext context,
                                                 Type serviceType,
                                                 ref ICollection<object> result)
    {
        if (context == null) return;

        foreach (object o in context.GetObjectsOfType(serviceType).Values)
        {
            result.Add(o);
        }

        GetAllInstancesRecursive(context.ParentContext, serviceType, ref result);
    } 

    public static IEnumerable<object> GetObjectsOfTypeRecursive(this IApplicationContext context, 
                                                                     Type serviceType)
    {
        ICollection<object> result = new Collection<object>();
        GetAllInstancesRecursive(context, serviceType, ref result);
        return result;
    }
}
Внимание! Вы собираетесь отправить информацию от имени анонимного пользователя.
v1.7.123.556
© 2009—2010 CodeHelper FAQ | О сайте | Обратная связь | История изменений | Статьи
Creative Commons LicenseМатериалы сайта распространяются под лицензией Creative Commons Attribution-Share Alike 3.0 Unported.