Scope configuration with attributes#25
Scope configuration with attributes#25dominikschlosser wants to merge 2 commits intoninject:masterfrom dominikschlosser:master
Conversation
|
But this makes the service to depend on Ninject.Extensions.Conventions |
|
Yes, you are right but it is just another option, you are not forced to use it. Coming from a java background, i really fell in love with the ease of use of CDI. To avoid dependencies on Ninject.Extensions.Conventions the added scope-attributes could be moved to a separate "interface"-project or, if you really want the possibility to not have any ninject-dependency in a loaded assembly, i could add a mechanism, where all attributes with the name "xyScoped" would be evaluated. |
Hi,
i have added attributes for the three default scopes (Singleton, Thread, Transient) and extended the configuration builder to auto-configure scopes by using these attributes.
This change is inspired by Java EE's Contexts and Dependency Injection (CDI) specification, where you are able to define contexts (scopes) via annotations.
Custom scopes can easily be added by creating a new attribute which inherits from "ScopeAttribute" and implements its abstract method "Configure".