以下样本显示如何以 Java™ 语言添加新的属性:
import com.rational.test.ft.domain.*; public class someProxy extends baseProxy { . . public java.util.Hashtable getProperties() { java.util.Hashtable properties = super.getProperties(); try { properties.put("toolTipText", getTooltipText()); } catch (Throwable e) { } // in the odd case we can't get the artifical properties, just ignore them. return properties; } . . . public Object getProperty(String propertyName) { if (propertyName.equals("toolTipText")) return getTooltipText(); return super.getProperty(propertyName); } }
以下样本显示如何以 .Net 形式添加新的属性:
using Rational.Test.Ft.Domain; public class AnyProxy:BaseProxy { . . . public override System.Collections.Hashtable GetProperties() { System.Collections.Hashtable propertyTable = base.GetProperties(); if( !propertyTable.Contains("ToolTipText")) { object text = GetToolTipText(); if (text != null) propertyTable.Add("ToolTipText", text ); } return propertyTable; } . . . public override object GetProperty(string propertyName) { object propertyValue = null ; if (propertyName == "ToolTipText" ) { propertyValue = GetToolTipText(); } else { propertyValue = base.GetProperty(propertyName) ; } return propertyValue ; }