I am not sure if this possible, but if I have a default constructor and something is invoking it (method, another constructor, a property, etc) is it possible to determine what type called it while in that constructor?
I am specifically interested in this use to regards to applying an attribute to a property.
Update : This question was answered by this : When is a custom attribute's constructor run?
Example :
[AttributeUsage(AttributeTargets.Property)]
public class SomeAttribute : Attribute
{
public Type InvokingType { get; private set; }
public SomeAttribute()
{
//InvokingType = the property it was applied to
}
}
public class SomeClass
{
[SomeAttribute]
public string SomeProperty { get; set; }
}