lundi 22 juin 2015

Get object by attribute value

I have a set of classes which implement a common interface and are annotated with a business domain attribute. By design, each class is annotated with different parametrization

[Foo(Bar=1)]
public class EntityA : ICustomInterface

[Foo(Bar=2)]
public class EntityB : ICustomInterface

[Foo(Bar=3)]
public class EntityC : ICustomInterface

Either From the Spring's IApplicationContext or using plain old reflection, how do I find the class that implements ICustomInterface and is annotated with [Foo(Bar=Y)]?

Something like Spring for Java's getBeansWithAnnotation. I don't require Spring.net, because those objects are prototypes. To be clear: if my task does not require using Spring at all I am happy with that





Aucun commentaire:

Enregistrer un commentaire