Dealing with dependencies
public interface IDependency
{
void DoSomething(string value);
}
public class MyService
{
private readonly IDependency _dependency;
public MyService (IDependency dependency)
{
_dependency = dependency ?? throw new ArgumentNullException(nameof(dependency));
}
public void SendCommand(string command)
{
_dependency.DoSomething(command);
}
}Last updated
Was this helpful?