<!--用Js模拟C#的Attribute-->
执行结果:<br>
<textarea rows = "10" cols = "100" id = "output"></textarea><br>
<br>
调试信息:<br>
<textarea rows = "10" cols = "100" id = "debug"></textarea><br>
<script language="javascript">
/* 特性(Attributes)是一种崭新的声明性信息。
我们不仅可以通过特性来定义设计层面的信息
(例如help file, URL for documentation)
以及运行时(run-time)信息(例如使XML与class相联系),
而且我们还可以利用特性建立自描述(self-describing)组件。
*/
function Attribute() //Attribute 基类,可以自行定义其中的接口以扩充功能,这里只是一个简单的演示,因此留空
{
}
function TestMethod() //定义一个新的Attribute类 TestMethod,用它来给需要进行单元测试的方法提供额外信息
{
this.name = "TestMethod";
}TestMethod.prototype = new Attribute();
function TestMethodAttribute() //必需的执行方法
{
return new TestMethod();
}
function DebugOutput(bOutput) //定义一个新的Attribute类 DebugOutput,用它来指示是否在测试中输出额外的调试信息
{
this.name = "DebugOutput";
this.