/// <summary> /// Creates a new ArcGIS Server REST Administration endpoint representation /// </summary> /// <param name="relativePath">Path of the endpoint relative to the root url of the ArcGIS Server</param> public ArcGISServerAdminEndpoint(string relativePath) { if (string.IsNullOrWhiteSpace(relativePath)) { throw new ArgumentNullException(nameof(relativePath), "relativePath is null."); } if (!Uri.TryCreate(relativePath, UriKind.RelativeOrAbsolute, out Uri 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("admin/", StringComparison.OrdinalIgnoreCase) > -1) { RelativeUrl = RelativeUrl.Substring(RelativeUrl.LastIndexOf("admin/", StringComparison.OrdinalIgnoreCase)); } RelativeUrl = RelativeUrl.Replace("admin/", ""); RelativeUrl = "admin/" + RelativeUrl.Trim('/'); }
/// <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); }