How to find a IComponentHandle by name in a stream?
How find a IComponentHandle by name in a stream?
I can use findComponents of IWorkspaceManager to get component, but if two streams have same component with name, how can I tell it?
Of course, I can use IWorkspaceConnection to filter stream, and get all components of IWorkspaceConnection. Then loop all component to filter the component out. But it cost too much time to compare all comopoent in stream.
So if any other easy method/api can be called to find out component by component name in a stream directly?
One answer
I can use findComponents of IWorkspaceManager to get component, but if two streams have same component with name, how can I tell it?I assume you mean the components are not the same (different UUID) but have the same name.
I don't think there's any useful API for finding a component by name in this instance. It's more reliable to refer to a component by its UUID.
If you're only starting with the component name, you'll have to fetch all the components in the stream and do the processing client-side.
Another possibility is using the findComponents call and get all the components from the stream then running a comparison check on the UUID. This might be faster depending on the number of components with the same name and if the findComponents result doesn't have multiple components in the stream.