bakagh

How to know if a layer is route layer?

Discussion created by bakagh on Jan 28, 2011
Latest reply on Feb 16, 2011 by bakagh
In my application, I need to know which layer is route layer.
The below is my code,sometimes it works(ayerEx1.ExtensionCount>0),but it doesn't work most of time(ayerEx1.ExtensionCount=0).
Please figure it out what is wrong?


IEnumLayer layers = axMapControl.Map.get_Layers(null, true);

            //get the layers from the maps
            layers.Reset();
            ILayer layer = layers.Next();
            while ((layer != null) && (layer is IFeatureLayer))
            {
                IFeatureLayer fLayer = (IFeatureLayer)layer;
                ILayerExtensions layerEx1 = (ILayerExtensions)fLayer;
                if (layerEx1.ExtensionCount != 0)
                {
                    for (int i = 0; i < layerEx1.ExtensionCount - 1; i++)
                    {
                        if ((layerEx.get_Extension(0)) is IRouteLayerExtension)
                        {
                            routelayers.Add(fLayer);
                        }
                    }
                }
                layer = layers.Next();
            }

Outcomes