Question
.NET CreateObject - How to call CollectionBase.Count on derived class
I am using an assembly that has an class like:
[SerializableAttribute] public class MetaDataDataCollection : CollectionBase
I have an instance of this class (retrieved via another method) but I cannot seem to call the Count method on this class or the List method (I just need the contents of this class). Any pointers on how I can get the information stored in the CollectionBase?
The CollectionBase List method is documented here: http://msdn.microsoft.com/en-us/library/system.collections.collectionbase.list.aspx It returns an IList.
Code:
function WriteEventMetadataTree(eventMetadata)
{
WriteOutput("<table>");
_WriteEventMetadataTree(eventMetadata, 2);
WriteOutput("</table>");
}
function _WriteEventMetadataTree(eventMetadata, depth)
{
for(i = 1; i lte ArrayLen(eventMetadata); i = i + 1)
{
metadata = eventMetadata;
WriteOutput("<tr>");
WriteOutput("<td>");
for(j = 1; j lte depth; j = j + 1)
{
WriteOutput(" ");
}
WriteOutput("</td><td>");
WriteOutput(metadata.Get_Name());
WriteOutput("</td>");
WriteOutput("</tr>");
metadataChildren = metadata.Get_Children(); // <-- This method returns a MetaDataDataCollection object
_WriteEventMetadataTree(metadataChildren.Get_List(), depth + 2);
}
}
...
<cfset a = WriteEventMetadataTree(eventMetadata) />
Result:
The Get_List method was not found.
Either there are no methods with the specified method name and argument types or the Get_List method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.
The error occurred in C:\inetpub\wwwroot\test.cfm: line 195
Called from C:\inetpub\wwwroot\test.cfm: line 175
Called from C:\inetpub\wwwroot\test.cfm: line 200
193 :
194 : metadataChildren = metadata.Get_Children();
195 : _WriteEventMetadataTree(metadataChildren.Get_List(), depth + 2);
196 : }
197 : }
