How can I put the following loops into one Linq query? The end result that I am trying to achieve is getting a list of Statements that are in those class methods.
Context: For every class, the corresponding methods are fetched with the classname. With every combination of classname / method name, I can call the metadata to get the source code (string). Then I compile that string and that Results in Method object that has and IEnumerable containing all of the code statements of that method. So I was to get the list of statements across all classes and methods.
IXppcMetadataProvider serviceMetadataProvider = Program.getXppcMetadataProvider();
IEnumerable<string> classNames = serviceMetadataProvider.ClassNames();
MultipassAdministrator multipassAdmin = new MultipassAdministrator(serviceMetadataProvider);
foreach (string className in classNames)
{
IEnumerable<string> classMethods = serviceMetadataProvider.ClassMethods(className);
foreach (string methodName in classMethods)
{
string source = serviceMetadataProvider.GetClassMethodSource(className, methodName);
Method method = multipassAdmin.CompileSingleMethod(source) as Method;
if (method != null)
{
foreach (Statement statement in method.Statements)
{
System.Console.WriteLine(statement.ToString());
}
}
}
}