Пример #1
0
        async public Task <IExplorerObject> CreateInstanceByFullName(string fullName, ISerializableExplorerObjectCache cache)
        {
            if (cache != null && cache.Contains(fullName))
            {
                return(cache[fullName]);
            }

            fullName = fullName.Replace("/", @"\");

            GeoServicesExplorerObjects          group = new GeoServicesExplorerObjects();
            GeoServicesConnectionExplorerObject connectionExObject = null;

            foreach (var connectionObject in (await group.ChildObjects()).OrderByDescending(e => e.FullName.Length))
            {
                if (fullName.StartsWith($@"{ connectionObject.FullName }\"))
                {
                    connectionExObject = connectionObject as GeoServicesConnectionExplorerObject;
                    break;
                }
            }

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

            string name = fullName.Substring(connectionExObject.FullName.Length + 1), folderName = "";

            IExplorerObject parentExObject = null;

            if (name.Contains(@"\"))
            {
                folderName     = name.Substring(0, name.LastIndexOf(@"\"));
                name           = name.Substring(name.LastIndexOf(@"\") + 1);
                parentExObject = await new GeoServicesFolderExplorerObject(null, String.Empty, String.Empty).CreateInstanceByFullName($@"{ connectionExObject.FullName }\{ folderName }", null);
            }
            else
            {
                parentExObject = connectionExObject;
            }


            var serviceExObject            = new GeoServicesServiceExplorerObject(parentExObject, name, folderName, connectionExObject._connectionString);

            if (serviceExObject != null)
            {
                if (cache != null)
                {
                    cache.Append(serviceExObject);
                }

                return(serviceExObject);
            }

            return(null);
        }
Пример #2
0
        async public Task <IExplorerObject> CreateInstanceByFullName(string fullName, ISerializableExplorerObjectCache cache)
        {
            if (cache != null && cache.Contains(fullName))
            {
                return(cache[fullName]);
            }

            fullName = fullName.Replace("/", @"\");

            GeoServicesExplorerObjects          group = new GeoServicesExplorerObjects();
            GeoServicesConnectionExplorerObject connectionExObject = null;

            foreach (var connectionObject in (await group.ChildObjects()).OrderByDescending(e => e.FullName.Length))
            {
                if (fullName.StartsWith($@"{ connectionObject.FullName }\"))
                {
                    connectionExObject = connectionObject as GeoServicesConnectionExplorerObject;
                    break;
                }
            }

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

            string name = fullName.Substring(connectionExObject.FullName.Length + 1);

            if (name.Contains(@"\"))
            {
                return(null);
            }

            var folderExObject = new GeoServicesFolderExplorerObject(connectionExObject, name, connectionExObject._connectionString);

            if (folderExObject != null)
            {
                if (cache != null)
                {
                    cache.Append(folderExObject);
                }

                return(folderExObject);
            }

            return(null);
        }
Пример #3
0
        async public Task <IExplorerObject> CreateInstanceByFullName(string FullName, ISerializableExplorerObjectCache cache)
        {
            if (cache.Contains(FullName))
            {
                return(cache[FullName]);
            }

            GeoServicesExplorerObjects group = new GeoServicesExplorerObjects();

            if (FullName.IndexOf(group.FullName) != 0 || FullName.Length < group.FullName.Length + 2)
            {
                return(null);
            }

            var exObject = (await group.ChildObjects()).Where(e => FullName.Equals(e.FullName)).FirstOrDefault();

            if (exObject != null)
            {
                cache.Append(exObject);
                return(exObject);
            }

            return(null);
        }