public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement) { IStructuralMatchResult match = Match(registrationRootElement); if (match.Matched) { var statements = match.GetMatchedElementList("statements").Cast<ICSharpStatement>(); var collectedTypes = statements.SelectMany(statement => { var returnTypeCollector = new ReturnTypeCollector(new UniversalContext(statement.GetPsiModule())); statement.ProcessThisAndDescendants(returnTypeCollector); return returnTypeCollector.CollectedTypes; }); foreach (var type in collectedTypes) { var declaredType = type as IDeclaredType; if (declaredType != null) { var typeElement = declaredType.GetTypeElement(); if (typeElement != null) { yield return new ServiceRegistration(registrationRootElement, typeElement); } } } } }
public override IEnumerable <IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement) { IStructuralMatchResult match = Match(registrationRootElement); if (match.Matched) { var statements = match.GetMatchedElementList("statements").Cast <ICSharpStatement>(); var collectedTypes = statements.SelectMany(statement => { var returnTypeCollector = new ReturnTypeCollector(new UniversalContext(statement.GetPsiModule())); statement.ProcessThisAndDescendants(returnTypeCollector); return(returnTypeCollector.CollectedTypes); }); foreach (var type in collectedTypes) { var declaredType = type as IDeclaredType; if (declaredType != null) { var typeElement = declaredType.GetTypeElement(); if (typeElement != null) { yield return(new ElementBasedOnRegistration(registrationRootElement, typeElement)); } } } } }