Hi ronik,
The unity container goes beyond just configuring and creating enterprise library objects. One way Unity can create objects for you automatically is by simply declaring the objects you need in your constructors.
public class Foo
{
IExceptionManager _em;
IDatabase _db;
IServiceAgent _sa; // custom made service agent for accessing some other web service
public Foo(IExceptionManager em, IDatabase db, IServiceAgent _sa)
{
_em = em;
_db = db;
_sa = sa;
}
}
In the example above the member level variables _em, _db and _sa will be created for you automatically by the Unity container. You can register any concrete type that map to your interfaces in the configuration file. You can even configure Unity to place proxy objects between the caller and the target object which can do things like logging, tracing, etc... (policy injection)
Dependency Injection and Policy Injection are complex subjects so I encourage you to read the Unity documentation that comes with EntLib and Unity. If you use Unity in key areas of your systems you'll have a lot of flexibility with mocking & unit testing, crosscutting concerns, instrumentation and health monitoring.