public IExplorerObject CreateInstanceByFullName(string FullName, ISerializableExplorerObjectCache cache) { try { if (cache.Contains(FullName)) { return(cache[FullName]); } FileInfo fi = new FileInfo(FullName); if (!fi.Exists || fi.Extension.ToLower() != ".mxl") { return(null); } MapDocumentExplorerObject ex = new MapDocumentExplorerObject(null, FullName); cache.Append(ex); return(ex); } catch { return(null); } }
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 mxlName = FullName.Substring(0, lastIndex); string mapName = FullName.Substring(lastIndex + 1, FullName.Length - lastIndex - 1); MapDocumentExplorerObject mapDocument = new MapDocumentExplorerObject(); mapDocument = await mapDocument.CreateInstanceByFullName(mxlName, cache) as MapDocumentExplorerObject; if (mapDocument == null || await mapDocument.ChildObjects() == null) { return(null); } foreach (MapExplorerObject mapObject in await mapDocument.ChildObjects()) { if (mapObject.Name == mapName) { cache.Append(mapObject); return(mapObject); } } return(null); }