コード例 #1
0
ファイル: ExplorerObjects.cs プロジェクト: jugstalt/gview5
        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 cnName = FullName.Substring(0, lastIndex);
            string svName = FullName.Substring(lastIndex + 1, FullName.Length - lastIndex - 1);

            WMSExplorerObject cnObject = new WMSExplorerObject(this);

            cnObject = await cnObject.CreateInstanceByFullName(cnName, cache) as WMSExplorerObject;

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

            foreach (IExplorerObject exObject in await cnObject.ChildObjects())
            {
                if (exObject.Name == svName)
                {
                    cache.Append(exObject);
                    return(exObject);
                }
            }
            return(null);
        }