0

I have multiple projects kind of multiple microservices, each microservice contain multiple projects with an api project.

What I want is to get all projects assemblies (load all application assemblies dynamically ) into a db or a json file or whatever . After that I’ll retrieve from each assembly api project list of all controllers. What I have done until now, is to get all controllers just for one assembly for one microservice (project).

This my code :

var result = Assembly.GetExecutingAssembly()
                                 .GetTypes()
                                 .Where(type => typeof(Controller).IsAssignableFrom(type))
                                 .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public))
                                 .Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any())
                                 .GroupBy(x => x.DeclaringType.Name) //just to get each action belong to correspondent controller
                                 .Select(x => new
                                 {
                                     Controller = x.Key,
                                     Actions = x.Select(s => s.Name).ToList()
                                 })
                                 .ToList();

Thanks in advance.

felipe
  • 11
  • 1
    Do you realize you have not asked anything? – Gusman May 29 '18 at 09:41
  • Possible duplicate of [C# Reflection: Get \*all\* active assemblies in a solution?](https://stackoverflow.com/questions/851248/c-sharp-reflection-get-all-active-assemblies-in-a-solution) – nilsK May 29 '18 at 09:42
  • Btw, is searched 'c# get all project assemblies'. First entry was stackoverflow with above linked post ... – nilsK May 29 '18 at 09:44
  • @Gusman : I said " What I want is to get all projects assemblies (load all application assemblies dynamically ) into a db or a json file or whatever . " – felipe May 29 '18 at 09:45
  • @nilsk for my case I want to get different assemblies from multiple projects (microservices) – felipe May 29 '18 at 10:04

0 Answers0