What is the advantage of UnityContainer.Resolve over Activator.CreateInstance?
.net, activator, c#, unity-container
Solution
MSDN states these as the advantages of Unity Container:
- Simplified object creation, especially for hierarchical object structures and dependencies
- Abstraction of requirements; this allows developers to specify dependencies at run time or in configuration and simplify management of crosscutting concerns
- Increased flexibility by deferring component configuration to the container
- Service location capability; this allows clients to store or cache the container
- Instance and type interception.
Here's the link.
Problem
I'm just getting started with Unity. I am still wondering what its advantages are. `UnityContainer().Resolve<T>()` which can return a concrete instance of the type that is registered for the generic type `T`. I think I can also use `Activator.CreateInstance<T>()`. `Activator` is a built-in class in the .NET Framework, so I am wondering what the distinct feature for Unity is?