4
似乎缺少UWP應用程序的靜態方法Attribute.IsDefined,我可以導航到Attribute類的元數據,並且方法在那裏,但是項目不會編譯,指出'Attribute'不包含定義'IsDefined' - 奇怪(事實上,根據IntelliSense,根本沒有這種類型的靜態方法)。是否有替換UWP應用中的Attribute.IsDefined?
我打算有特定屬性來查詢類型,如
var types = this.GetType().GetTypeInfo().Assembly.GetTypes()
.Where(t => Attribute.IsDefined(t, typeof (MyAttribute)));
,我想知道如果有一種變通方法。
工程就像一個魅力,非常感謝! –
嗯。 GetCustomAttribute接受類型'Type'的第一個參數也找不到。 – ickydime
這似乎爲我工作:http://stackoverflow.com/questions/30972197/system-type-has-no-definition-for-getcustomattribute-in-net35 – ickydime