Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity extension

I inherited some code with a custom DI container ( which needs to be moved to unity ) which is attribute based like MEF e.g.

[SERVICE]
PUBLIC <interface> myVar { get; set ; }

wondering if there already is a unity extension which i could use or maybe any help on building one ?

like image 778
Kumar Avatar asked Apr 24 '26 04:04

Kumar


1 Answers

Its not clear what behavior [SERVICE] is suppose to enable. So I'll guess:

Out of the box Unity supports Injection Attributes for different forms of dependency injection. You can also do Attribute-Driven Policies for method interception.

If you have the flexibility to change how injection is done: The preferred pattern is to use constructor injection instead of attributes or service locator. It allows you to remove all references to Unity from you classes... which means you can change containers again without code changes. See Service Locator is an Anti-Pattern.

like image 156
ErnieL Avatar answered Apr 25 '26 17:04

ErnieL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!