When injecting dependencies into a constructor, I'm not quite sure if it breaks SOLID if I do the following:
public MyClass(IConfiguration configuration)
{
_port = configuration.GetValue("Port");
}
instead of passing the pure value like so:
public MyClass(int port)
{
_port = port;
}
The first one seems to be some kind of a Service Locator.
Question here is: Is it okay to pass complex dependencies just to retrieve a single value the class actually relies on?
To me it doesn't look that wrong, but it unnecessarily hides the real dependency which could get passed much easier.