concept Dependencies in category dependency injection

appears as: Dependencies, Dependencies, The Dependencies
Dependency Injection

This is an excerpt from Manning's book Dependency Injection.

Perhaps the most dangerous fallacy is that DI involves some sort of general-purpose Abstract Factory that you can use to create instances of the Dependencies needed in your applications.

Listing 5.18 Factory that creates SqlProductRepository instances
public class SqlProductRepositoryFactory
    : IProductRepositoryFactory
{
    private readonly string connectionString;

    public SqlProductRepositoryFactory(
        IConfigurationRoot configuration)    #1  
    {
        this.connectionString =
            configuration.GetConnectionString(    #2  
                "CommerceConnectionString");
    }

    public IProductRepository Create()
    {
        return new SqlProductRepository(    #3  
            new AspNetUserContextAdapter(),
            new CommerceContext(this.connectionString));
    }
}

#1   Constructor with a particular signature that all IProductRepositoryFactory implementations must have. By accepting Microsoft’s IConfigurationRoot, the factory loads its required configuration values. It also throws an error during construction in case such a value is missing.
#2   Loads the connection string from the configuration file and stores it for later use
#3   Creates a new SqlProductRepository using Dependencies that are located in different assemblies

When we accept that we should let go of our psychological need for control over Dependencies and instead request them through Constructor Injection or one of the other DI patterns, we must let go completely. To understand why, we’ll examine the issue progressively. Let’s begin by reviewing what the standard .NET object lifecycle means for Dependencies. You likely already know this, but bear with us for the next half page while we establish the context.