Ejemplo n.º 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 dsName = FullName.Substring(0, lastIndex);
            string fcName = FullName.Substring(lastIndex + 1, FullName.Length - lastIndex - 1);

            CosmoDbExplorerObject dsObject = new CosmoDbExplorerObject();

            dsObject = await dsObject.CreateInstanceByFullName(dsName, cache) as CosmoDbExplorerObject;

            var childObjects = await dsObject?.ChildObjects();

            if (childObjects == null)
            {
                return(null);
            }

            foreach (IExplorerObject exObject in childObjects)
            {
                if (exObject.Name == fcName)
                {
                    cache.Append(exObject);
                    return(exObject);
                }
            }
            return(null);
        }