I'm trying to build a little "autonomous" object factory that is using reflection and attributes to know what are the available object types.
Actually, the custom attribute looks like
<ObjectFactory(13)>
Where 13 is the object type id. So say in my DB I have an object for which I stored the object ID 13, now I simply call the factory with GetTypedObject(objectId) and it will extract the constructor from a dictionary based on ObjectTypeId.
Since the classes using this attribute must have a specific constructor to be a valid Factory builder, I had a method looking for this constructor within the factory but I thought that this role should go to the attribute itself so I started to move this logic and that is when I faced my problem:
how can I access the type of the class to which this attribute is attached?
Thank you for your help!
Actually, the custom attribute looks like
<ObjectFactory(13)>
Where 13 is the object type id. So say in my DB I have an object for which I stored the object ID 13, now I simply call the factory with GetTypedObject(objectId) and it will extract the constructor from a dictionary based on ObjectTypeId.
Since the classes using this attribute must have a specific constructor to be a valid Factory builder, I had a method looking for this constructor within the factory but I thought that this role should go to the attribute itself so I started to move this logic and that is when I faced my problem:
how can I access the type of the class to which this attribute is attached?
Thank you for your help!