Unable to check if layer or standalone table can be created from an Item

477
0
09-19-2017 07:27 PM
MaxMax2
Occasional Contributor II

I need to add temporary layer or standalone table when user specifies the path to a dataset. To accomplish this task I create an instance of the Item via ItemFactory:

var item = ItemFactory.Instance.Create(path, ItemFactory.ItemType.PathItem);

And then I check if a layer or standalone table can be created from the item using corresponding methods of LayerFactory and StandaloneTableFactory:

if (LayerFactory.Instance.CanCreateLayerFrom(item))
    return LayerFactory.Instance.CreateFeatureLayer(item, MapView.Active.Map);

if (StandaloneTableFactory.Instance.CanCreateStandaloneTableFrom(item))
    return StandaloneTableFactory.Instance.CreateStandaloneTable(item, MapView.Active.Map);‍‍‍‍‍

But both CanCreateLayerFrom and CanCreateStandaloneTableFrom methods don't work properly. They always return true regardless of what the type an item of. If I create an item from a feature class, the CanCreateStandaloneTableFrom returns true for this item. If I create an item from a table, the CanCreateLayerFrom returns true for the item. It is definitely wrong. With this behavior the code above works incorrectly.

Also both CreateFeatureLayer and CreateStandaloneTable create an item in the TOC even if they return null.

Please fix this issues. Also can you suggest a workaround while you are fixing the bugs?

Tags (2)
0 Kudos
0 Replies