Beispiel #1
0
        async public Task <IExplorerObject> CreateInstanceByFullName(string FullName, ISerializableExplorerObjectCache cache)
        {
            if (cache.Contains(FullName))
            {
                return(cache[FullName]);
            }

            FullName = FullName.Replace("/", @"\");
            int lastIndex = FullName.LastIndexOf(@"\");

            if (lastIndex == -1)
            {
                return(null);
            }

            string mapName = FullName.Substring(0, lastIndex);
            string mflName = FullName.Substring(lastIndex + 1, FullName.Length - lastIndex - 1);

            MapExplorerObject mapObject = new MapExplorerObject();

            mapObject = await mapObject.CreateInstanceByFullName(mapName, cache) as MapExplorerObject;

            if (mapObject == null || await mapObject.ChildObjects() == null)
            {
                return(null);
            }

            foreach (FeatureLayerExplorerObject mflObject in await mapObject.ChildObjects())
            {
                if (mflObject.Name == mflName)
                {
                    cache.Append(mflObject);
                    return(mflObject);
                }
            }
            return(null);
        }
Beispiel #2
0
        public IExplorerObject CreateInstanceByFullName(string FullName, ISerializableExplorerObjectCache cache)
        {
            try
            {
                if (cache.Contains(FullName))
                {
                    return(cache[FullName]);
                }

                FullName = FullName.Replace("/", @"\");
                int lastIndex = FullName.LastIndexOf(@"\");
                if (lastIndex == -1)
                {
                    return(null);
                }

                string parentName = FullName.Substring(0, lastIndex);
                string tocName    = FullName.Substring(lastIndex + 1, FullName.Length - lastIndex - 1);

                lastIndex = parentName.LastIndexOf(@"\");
                if (lastIndex == -1)
                {
                    return(null);
                }
                string   mapDocname = parentName.Substring(0, lastIndex);
                FileInfo mapDoc     = new FileInfo(mapDocname);
                if (mapDoc.Exists)
                {
                    MapExplorerObject mapObject = new MapExplorerObject();
                    mapObject = mapObject.CreateInstanceByFullName(parentName, cache) as MapExplorerObject;
                    if (mapObject == null || mapObject.ChildObjects == null)
                    {
                        return(null);
                    }

                    foreach (TOCElementExplorerObject tocObject in mapObject.ChildObjects)
                    {
                        if (tocObject.Name == tocName)
                        {
                            cache.Append(tocObject);
                            return(tocObject);
                        }
                    }
                }
                else
                {
                    TOCGroupElementExplorerObject parentTocObject = new TOCGroupElementExplorerObject();
                    parentTocObject = parentTocObject.CreateInstanceByFullName(parentName, cache) as TOCGroupElementExplorerObject;
                    if (parentTocObject == null || parentTocObject.ChildObjects == null)
                    {
                        return(null);
                    }

                    foreach (TOCElementExplorerObject tocObject in parentTocObject.ChildObjects)
                    {
                        if (tocObject.Name == tocName)
                        {
                            cache.Append(tocObject);
                            return(tocObject);
                        }
                    }
                }
            }
            catch
            {
            }
            return(null);
        }