Update: Based on the answers I initially went the route of using IsInstanceOf() which was designed for this need. However it turned out to be extremely inefficient for some unknown reason. In debugging the app later I ended up just setting some properties on the object to use instead of IsInstanceOf resulting in orders of magnitude speed improvement.
我想做的是在 ColdFusion 中测试一个对象,看看它是什么类型的组件。就像是...
<cfif isValid( "compath.dog", currentObj)>
...do something specific with dog objects...
</cfif>
我认为这是可能的,但收到一条错误消息,指出我传递的类型与有效类型列表中的类型不对应...
Valid type arguments are: any, array, Boolean, date, numeric, query, string, struct, UUID, GUID, binary, integer, float, eurodate, time, creditcard, email, ssn, telephone, zipcode, url, regex, range , component, or variableName.
有没有办法在 ColdFusion 中实现这一点?
最佳答案
您可以使用 GetMetaData 来查找类型。一些快速代码:
<cfif GetMetaData(currentObj).type eq "compath.dog">
关于coldfusion - 是否可以针对组件类型和/或继承类型测试对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/879388/