title: How to determine if service has already been added to IServiceCollection
body: <p>I am creating helper classes to simplify configuration and injection of interfaces via <code>IServiceCollection</code> for a library. The libraries constructor contains a number of dependencies that are likely to have been injected earlier. If they aren't already inserted into <code>IServiceCollection</code>, the helper class should add them. How do I detect if the interface has already been injected?</p>
  
  <pre><code>public static void AddClassLibrary(this IServiceCollection services
      , IConfiguration configuration)
  {
       //Constructor for ClassLibrary requires LibraryConfig and IClass2 to be in place
       //TODO: check IServiceCollection to see if IClass2 is already in the collection. 
       //if not, add call helper class to add IClass2 to collection. 
       //How do I check to see if IClass2 is already in the collection?
       services.ConfigurePOCO&lt;LibraryConfig&gt;(configuration.GetSection("ConfigSection"));
       services.AddScoped&lt;IClass1, ClassLibrary&gt;();
  }
  </code></pre>