- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我创建了以下 javascript 对象:
var Content = Content || {};
// Constructor defines properties and inits object
Content.ProductManager = function () {
// ...
};
Content.ProductManager.prototype = function () {
//
// private members
//
var setProductAsPreviewed = function (args) {
// code omitted for brevity
// ....
};
//
// public members
//
return {
setProductAsPreviewed: setProductAsPreviewed
};
} ();
传递给 setProductAsPreviewed
的对象具有以下属性:
args = {
productId: int,
productName: string,
updateDate: date,
saveItems: bool
};
我想包含 XML 注释,这样我就可以获得传递给函数 setProductAsPreviewed
的参数的智能感知:
var productManager = new window.Content.ProductManager();
// show intellisense when typing the following:
productManager.setProductAsPreviewed(
This thread显示了如何为简单的 args(string
、int
、...)执行此操作,但如何为复杂的对象执行此操作?我正在使用 Visual Studio 2010。
最佳答案
据我所知,如果泛型变量用作参数,您无法告诉 IntelliSense 哪些字段和方法在泛型变量上。
如果变量是一个数组,你可以这样定义它:
function funcWithArrayArg(arrayArg) {
/// <param name="arrayArg" type="Array" elementType="Number">An array of numbers</param>
}
在 VS2012 中,您也可以像这样注释对象(您可以在用作对象构造函数的函数上注释字段,正如我在下面演示的那样,但文档没有提到像这样的匿名对象):
var args = {
/// <field type="Number">Product ID</field>
productID: int
};
这两种方法都不能真正满足您的需求,因为第二种方法不会为您提供函数参数的智能感知,而且您仍然在使用 VS2010。
我认为你最好的选择是定义一个自定义对象作为该函数的参数对象,毕竟如果你想创建一个自定义对象作为参数,这就是你在其他语言中的做法智能感知。它可能看起来像这样:
function ProductPreviewArgs(productId, productName, updateDate, saveItems) {
/// <summary>Creates an object for use as the sole argument to the setProductAsPreviewed function</summary>
/// <param name="productId" type="Number" optional="false">The Product ID</param>
/// <param name="productName" type="String" optional="false">The Product Name</param>
/// <param name="updateDate" type="Date" optional="false">The date the product was last updated</param>
/// <param name="saveItems" type="Boolean" optional="false">Specifies whether or not to save the items</param>
/// <returns type="ProductPreviewArgs">An object intended for use as the sole argument to the setProductAsPreviewed function</returns>
/// <field name="productId" type="Number">The Product ID</field>
/// <field name="productName" type="String">The Product Name</field>
/// <field name="updateDate" type="Date">The date the product was last updated</field>
/// <field name="saveItems" type="Boolean">Specifies whether or not to save the items</field>
this.productId = productId;
this.productName = productName;
this.updateDate = updateDate;
this.saveItems = saveItems;
}
您将在此处获得对象的智能感知(它将显示您在 returns
元素中放置的内容):
setProductAsPreviewed(
如果您随后决定创建一个新对象,您将在此处获得 IntelliSense(它将在您添加每个参数时一一显示它们的描述):
setProductAsPreviewed(new ProductPreviewArgs(
我不完全确定 returns
元素上的 type
属性是否真的像那样工作,它在 VS2012 中确实如此,正如您可能期望的那样现在,文档在这个问题上令人恼火;而且我现在没有 VS2010 的副本来测试这些。
关于javascript - Visual Studio - javascript 自定义对象的智能感知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16709511/
是否可以有DropShadowEffect渲染阴影时忽略某些颜色?有某种蒙版(颜色选择性)阴影? 我的问题是什么阴影可以分配给整个视觉元素(图形)。它看起来像这样: 而且我要 注意没有阴影的网格线(除
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, over
有时,当我尝试使用 maven mvn clean install jetty:run 运行我的项目时,它会返回一个错误消息:“地址已在使用中”。 我正在使用 Intellij IDEA 14。 你能
我见过几个数据库缓存引擎,它们都非常愚蠢(即:将此查询缓存 X 分钟)并要求您在 之后手动删除整个缓存存储库>INSERT/UPDATE/DELETE 查询已执行。 大约 2 或 3 年前,我为我正在
我正在寻找例程或寻找错误容忍字符串比较的方法。 比方说,我们有测试字符串 Čakánka - 是的,它包含 CE 字符。 现在,我想接受以下任何字符串作为 OK: 恰坎卡 cákanká ÇaKaNK
大家好 我在 windows xp 系统上使用智能 gwt 2.3 专业版和 Mozilla。 我在上面做了测试应用程序,它运行成功。 现在我想为此应用程序使用开发人员控制台。 我的gwt.xml 编
说,我有 member this.Test (x: 'a) = printfn "generic" 1 member this.Test (x:
我正在努力寻找有关如何将应用程序部署到索尼智能 watch 的任何文档或教程(我正在尝试部署由索尼编写的开源“Eight Puzzle”应用程序,我已将其导入到 Eclipse 中。我有一个三星 S3
我正在寻找一个类似于标准格式化程序的智能 Java 字符串格式化程序: StringBuffer buffer = new StringBuffer(); Formatter form
我有一个智能 JScrollPane,但与其他所有解决方案不同,我想知道如果滚动 Pane 不在底部并且文本是否可以跟随(向上滚动)查看的组件(JTextArea)缓冲区已满。包含功能齐全的代码片段。
我有一个包含 18 个类(class)的项目。它们正在工作线程保存(已检查),没有递归调用,也没有任何复杂的计算。 但是我的IDEA总是说几个小时后 There is not enough memor
我想使用 Smart XLS 库在 C# 中处理 excel 文件(特别是因为它可以生成图表,而且它的价格明显低于 Aspose Cells),但我找不到任何好的例子。我只想知道如何创建和修改图表,有
我正在寻找一个完整的 java 日期管理库,它可以让我理解像这样的字符串: 明天中午 => 2011-10-20 12:00 今天下午 4 点 => 2011-10-20 16:00 等... 但如果
我想打开手机中的文件,通过 watch 中的 Action ... 问题是: Intent intent2 = new Intent(); intent2.setAction(android.cont
我想编译 Sony 为他的 SmartWatch 提供的示例。我按照此 page 中的说明进行操作.但是当我添加 SmartExtensionUtils 项目时,我看到了很多错误,例如:com.son
我有一个 SQL 表:名称、位置、体积 名称为字符串类型 位置是两个 float 类型的字段(纬度和经度) int 类型的体积 我想运行一个 SQL 查询,该查询将对特定范围内的所有位置进行分组并对所
我需要找到当我点击某物时调用的方法。项目很大,自己找会花不少时间。有什么办法可以做到吗?我正在使用 Android Studio,是的,这是我有史以来第一次使用其他人的项目。 最佳答案 我是怎么做到的
我在我的 iMac 上安装了智能 cvs,我已经从 cvs 更新了应用程序。然后我对我的代码和核心数据做了一些更改(核心数据更改是:从核心数据实体中删除一些属性),然后我尝试将更改提交给 cvs,但我
在我的 Java 项目中,我有一个类 Person,它存在于两个具有相同包名 (com.example.beans) 的不同 jar 中。 问题是这个类在jar1中是这样定义的: class Pers
已关闭。此问题旨在寻求有关书籍、工具、软件库等的建议。不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以
我是一名优秀的程序员,十分优秀!