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 ?
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.
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