1
표현 트리에서 PropertyDescriptor
을 얻는 명확한 방법이 있습니까?표현 트리 및 PropertyDescriptor
, 내 코드를 나는 현재 PropertyInfo
가지고 있지만 내가 이상적으로 PropertyDescriptor
원하는 :
var prop =
(System.Reflection.PropertyInfo)
((MemberExpression)
((Expression<Func<TestClass, long>>)
(p => p.ID)).Body).Member;
내가 사용해야하기 때문에 PropertyDescriptor를위한 나의 필요가있다
:
if (prop.CanResetValue(this))
{
prop.ResetValue(this);
}
else
{
prop.SetValue(this, null);
}
내가 PropertyInfo.SetValue(this, null, null)
을 사용할 수 없습니다 그렇지 않은으로 내 요구에 맞게, DefaultValueAttribute
으로 지정된 기본값으로 재설정해야합니다.
좋은 간단한,'PropertyDescriptorCollection'은 단지'int' 지수 작동하는지 나에게 말하고 있었다하지'string'는 VS2010를 재설정하면 해당 문제를 해결 한 것으로 보인다. – Seph