[在 CSS 类的 HTMLHelper 属性上启用智能感知]
我有这个 HTMLhelper:
public IHtmlString MyTextBoxFor<TModel, TProperty>(
this HtmlHelper<TModel> html,
Expression<Func<TModel, TProperty>> propertyExpression,
string cssClass)
{
// ...
}
我希望 Resharper 在传递“cssClass”参数的值时为我的应用程序中定义的 CSS 类提供 IntelliSense。
Resharper 可以识别一些代码注释属性,但似乎没有一个与将方法参数标记为 CSS 类直接相关。
我能找到的最接近的是[HtmlAttributeValue(string name)]。我试图像这样应用到 cssClass 参数:
public IHtmlString MyTextBoxFor<TModel, TProperty>(
this HtmlHelper<TModel> html,
Expression<Func<TModel, TProperty>> propertyExpression,
[HtmlAttributeValue("class")] string cssClass)
{
// ...
}
但这不起作用。如果 Resharper 能够识别输入的类并停止在 jQuery 选择器表达式(在上面的帮助器生成的文本框上运行)中的未知 CSS 类的问题,那也将是非常棒的。
编辑: 这是用于操作方法的“htmlAttributes”参数的智能感知类型的屏幕截图。这是通过在参数上使用 [HtmlElementAttributes] 注释来完成的。
我想要一个类似的注释,让我将 css 类放在一个字符串参数中,并让相同的智能感知显示 css 类。