Resolving all services through dependency injection in Griffin.Container

Bookmark and Share

I’ve just added a new feature to Griffin.Container: Support for resolving all implementations of a service by using constructors.

You can now do something like this:

public interface IStatefulService
{
	void Ping();
}

public class FtpConnection : IStatefulService
{
}

public class Pop3Connection : IStatefulService
{
}

public class ConnectionPinger
{
	public ConnectionPinger(IEnumerable<IStatefulService> services)
	{
		_services = services;
	}
	
	public void PingAll()
	{
		_services.Each(x => x.Ping());
	}
}

Griffin.Container can be found at github.

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.