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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With