You can overload the constructor and just call them unless you have a need to
call instantiate the object via reflection (which is one of the slowest
reflection operations). Or you could (although this too is slow) inspect the
stack trace in the constructor to see who created the object.
Or you could have a static property on the object type which you can set
with information for the constructor to use. You could make this thread safe
by marking it with the ThreadStatic attribute.
I prefer the overloaded contructor option. Its the 'normal' way of coding,
the other are for if you need them for a reason.
HTH
Ciaran O'Donnell
"Søren M. Olesen" wrote:
>
Hi
Is it (any way) possible using reflection to set an indicator (property,
variable, attribute,..). on an object before it actually instantiated, so
that this indicator can be used in the constructor to determine how the was
created, or who created the object.. ??
TIA
Søren