何らかの理由で、私はこれを取得していません。(以下のモデル例)私が書くと:
var property = typeof(sedan).GetProperty("TurningRadius");
Attribute.GetCustomAttributes(property,typeof(MyAttribute), false)
継承チェーンを検索したくないことを示しているにもかかわらず、呼び出しは MyAttribute(2) を返します。呼び出すために私が書くことができるコードを誰かが知っていますか
MagicAttributeSearcher(typeof(Sedan).GetProperty("TurningRadius"))
呼び出し中に何も返さない
MagicAttributeSearcher(typeof(Vehicle).GetProperty("TurningRadius"))
MyAttribute(1) を返しますか?
モデル例:
public class Sedan : Car
{
// ...
}
public class Car : Vehicle
{
[MyAttribute(2)]
public override int TurningRadius { get; set; }
}
public abstract class Vehicle
{
[MyAttribute(1)]
public virtual int TurningRadius { get; set; }
}