سؤال

Suppose I have a class as follows where MyProperty is composed in by MEF:

class Foo
{
    [Import]
    public Bar MyProperty { get; set; }
}

While using reflection to inspect this assembly, is it possible to determine whether the property was imported by MEF? I noticed an Attributes property in the PropertyInfo class but it was empty.

هل كانت مفيدة؟

المحلول

You should use the GetCustomAttributes() method instead.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top