I've got some code that iterates through all datasets and subsets in a workspace. When I get to an instance of an IDataset for a geometric network and access the Subsets property, I get the NotImplementedException. Is this by design?

I've got some code that iterates through all datasets and subsets in a workspace. When I get to an instance of an IDataset for a geometric network and access the Subsets property, I get the NotImplementedException. Is this by design?

- "... IDataset::Subsets is not supported for Graph objects such as a Geometric Network. To return the feature classes contained in a Geometric Network, use the IFeatureClassContainer interface...."

see**Remarks**http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Subsets_Property/00250000017z000000/ "... IDataset::Subsets is not supported for Graph objects such as a Geometric Network. To return the feature classes contained in a Geometric Network, use the IFeatureClassContainer interface...."

see**Remarks**http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Subsets_Property/00250000017z000000/

I�??ve seen the documentation, but it still doesn�??t make sense to me. If a Geometric Network, or some other Graph object, doesn�??t require a Subsets property, then it isn�??t really an IDataset�??IDataset is an interface that describes the functionality that a dataset has, so if Graph objects don�??t have Subsets then they aren�??t really datasets (as defined by the IDataset interface.) See http://en.wikipedia.org/wiki/Interface_segregation_principle for more details.

That said, it is what it is. So, my next question is how can I tell if an object that implements IDataset has Subsets implemented?

Are Graph objects the only types that don�??t have Subsets implemented? If so, how do I tell which objects are Graph objects (http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/esriDatasetType_Constants/002500000042000000/)?- I think that NotImplementedException/NotSupportedException- not everything is available.

For instance, you can have interfaces that support a pair "CanUseFind?" / "Find". If the "CanUseFind?" returns false, it is reasonable "Find" throw NotSupportedException.

Here for particular data (Graph) is used IFeatureClassContainer.

you catch this error for see if implemented this method. I think that NotImplementedException/NotSupportedException- not everything is available.

For instance, you can have interfaces that support a pair "CanUseFind?" / "Find". If the "CanUseFind?" returns false, it is reasonable "Find" throw NotSupportedException.

Here for particular data (Graph) is used IFeatureClassContainer.

you catch this error for see if implemented this method.

NotImplementedException is generally used to indicate that an implementation is not available currently, but will be available in the future. It is a placeholder for unfinished code.

NotSupportedException is used when a derived class doesn't implement all of the unsupported methods of a base class (abstract methods, interface methods, etc.)

"There are methods that are not supported in the base class, with the expectation that these methods will be implemented in the derived classes instead. The derived class might implement only a subset of the methods from the base class, and throw NotSupportedException for the unsupported methods." --http://msdn.microsoft.com/en-us/library/system.notsupportedexception.aspx

It seems like there are at least a couple of ways around my problem (since using exceptions for normal flow of control is a horrible coding practice):

1) Will checking the dataset's type to see if it is esriDatasetType.esriDTContainer allow me to filter out all Graph objects? If so, are there other objects that don't support Subsets that also need to be filtered so that I don't get an exception when I get Subsets?// if not a container, check for subsets if (_dataset.Type != esriDatasetType.esriDTContainer )

2) If a dataset doesn't implement the IFeatureClassContainer interface, does that guarantee that Subsets will not throw an exception? Or, are there other implementations of IDataset that throw some kind of exception when getting the Subsets?// if dataset doesn't implement IFeatureClassContainer, check for subsets if (!(_dataset is IFeatureClassContainer))

- In help is written that IDataset::Subsets is not supported for Graph.

2) IGraph is implemented only from geometric Network class so Subsets will throw an exception only geometric Network.

1) you can check if you have a gn in container (you can have only 1 gn in container) for know if you have a graph and so ...(see 2)

I agree "...since using exceptions for normal flow of control is a horrible coding practice..." In help is written that IDataset::Subsets is not supported for Graph.

2) IGraph is implemented only from geometric Network class so Subsets will throw an exception only geometric Network.

1) you can check if you have a gn in container (you can have only 1 gn in container) for know if you have a graph and so ...(see 2)

I agree "...since using exceptions for normal flow of control is a horrible coding practice..."

Ok. I think this is the answer I was looking for. From the help that you quoted in your first response: "IDataset::Subsets is not supported for Graph objects such as a Geometric Network." Graph objects are the only objects that do not support IDataset::Subsets. Further, GeometryNetwork is the only CoClass that implements IGraph and therefore the only IDataset object, to date, that doesn't implement IDataset::Subsets.

It seems like the best way for me to avoid the exception then is to do the following:if(!(dataset is IGraph )) // something with dataset.Subsets

That way, if any Graph objects are added in the future, my code will not break.

Ok. I think this is the answer I was looking for. From the help that you quoted in your first response: "IDataset::Subsets is not supported for Graph objects such as a Geometric Network." Graph objects are the only objects that do not support IDataset::Subsets. Further, GeometryNetwork is the only CoClass that implements IGraph and therefore the only IDataset object, to date, that doesn't implement IDataset::Subsets.

It seems like the best way for me to avoid the exception then is to do the following:

That way, if any Graph objects are added in the future, my code will not break.