Exemple #1
0
        /// <summary>
        /// Creates a new ArcGIS Server REST endpoint representation
        /// </summary>
        /// <param name="relativePath">Path of the endpoint relative to the root url of the ArcGIS Server</param>
        public ArcGISServerEndpoint(string relativePath)
        {
            if (string.IsNullOrWhiteSpace(relativePath))
            {
                throw new ArgumentNullException(nameof(relativePath), "relativePath is null.");
            }

            Uri uri;

            if (!Uri.TryCreate(relativePath, UriKind.RelativeOrAbsolute, out uri))
            {
                throw new InvalidOperationException("Not a valid relative url " + relativePath);
            }

            if (uri.IsAbsoluteUri)
            {
                RelativeUrl = uri.AbsolutePath.Trim('/') + "/";
            }
            else
            {
                RelativeUrl = uri.OriginalString.Trim('/') + "/";
            }

            if (RelativeUrl.IndexOf("rest/services/", StringComparison.OrdinalIgnoreCase) > -1)
            {
                RelativeUrl = RelativeUrl.Substring(RelativeUrl.LastIndexOf("rest/services/", StringComparison.OrdinalIgnoreCase));
            }
            RelativeUrl = RelativeUrl.Replace("rest/services/", "");
            RelativeUrl = "rest/services/" + RelativeUrl.Trim('/');
        }
Exemple #2
0
        /// <summary>
        /// Creates a new ArcGIS Online or Portal REST endpoint representation
        /// </summary>
        /// <param name="relativePath">Path of the endpoint relative to the root url of ArcGIS Online / Portal</param>
        public ArcGISOnlineEndpoint(String relativePath)
        {
            if (String.IsNullOrWhiteSpace(relativePath))
            {
                throw new ArgumentNullException("relativePath");
            }
            RelativeUrl = relativePath.Trim('/');
            if (RelativeUrl.IndexOf("sharing/rest") > 0)
            {
                RelativeUrl = RelativeUrl.Substring(RelativeUrl.IndexOf("sharing/rest"));
            }
            RelativeUrl = RelativeUrl.Replace("sharing/rest/", "");

            System.Diagnostics.Debug.WriteLine("Created ArcGISOnlineEndpoint for " + RelativeUrl);
        }