Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Unity InjectionConstructor Attribute?

What is Unity InjectionConstructor Attribute and how it works ?

like image 382
Yoann. B Avatar asked Jan 19 '09 17:01

Yoann. B


People also ask

What is Injectionconstructor?

A class that holds the collection of information for a constructor, so that the container can be configured to call this constructor.

What is Unitycontainer C#?

The Unity Container (Unity) is a full featured, extensible dependency injection container. It facilitates building loosely coupled applications and provides developers with the following advantages: Simplified object creation, especially for hierarchical object structures and dependencies.

How do I register a type with unity container?

Before Unity resolves the dependencies, we need to register the type-mapping with the container, so that it can create the correct object for the given type. Use the RegisterType() method to register a type mapping. Basically, it configures which class to instantiate for which interface or base class.


1 Answers

Basically this tells Unity to use the constructor that is specified with the attribute. Please read this post for more information.

like image 104
Ryan Lanciaux Avatar answered Sep 21 '22 21:09

Ryan Lanciaux