私はPropertyInfo
次のようにリストをフィルタリングしています:
foreach (PropertyInfo propertyInfo in
ClassUtils.GetProperties(patternType).
Where(pi => pi.GetCustomAttribute<TemplateParamAttribute>() != null).
OrderBy(pi1 => pi1.GetCustomAttribute<TemplateParamAttribute>().Order))
{
TemplateParamAttribute attr = propertyInfo.GetCustomAttribute<TemplateParamAttribute>();
...
GetCustomAttribute
これは正しく機能しますが、各反復で 3 回の呼び出しに満足していません。呼び出しの数を減らすGetCustomAttribute
(それでも linq を使用する) 方法はありますか?