title: Add singleton to IServiceCollection dynamically in a loop
body: <p>Hi I have an interface which is implemented by multiple classes.</p>
  
  <pre><code>public interface IHuman
  {
      void Talk();
  }
  
  public class AdultHuman
  {
      public void Talk()
      {
            Console.Writeline("Hi");
      }
  }
  
  public class BabyHuman
  {
       public void Talk()
      {
            Console.Writeline("Babble");
      }
  }
  
  
  public enum HumanEnums
  {
      Adult,
      Baby
  }
  </code></pre>
  
  <p>Currently in my startup add on I have </p>
  
  <pre><code>services.AddSingleton&lt;AdultHuman&gt;();
  services.AddSingleton&lt;BabyHuman&gt;();
  </code></pre>
  
  <p>We are constantly adding different implementations of IHumans so I would like my start up add on to be dynamic to add the singletons with a forloop looping through the values of the HumanEnums so it would look like this</p>
  
  <pre><code>var enumTypes = Enum.GetValues(typeof(ActionTypes));
  foreach(var enum in enumTypes)
  {
       var type = typeof(IHuman);
  
       // namespace + name of class i.e MyProgram.Humans.BabyHuman
       var typeName = $"{type.Namespace}.{action}Human";
       var t = Type.GetType(typeName, true);
       services.AddSingleton&lt; --something here-- &gt;();
  }
  </code></pre>
  
  <p>How would I achieve this? </p>
  
  <p>P.S. Also it would be helpful if instead of looping through the enums, I could find all implementations of IHuman and loop through that.</p>