public Uri GetEffectivePathForPrompt() { if (BaseAddress == null) { return(null); } return(GetEffectivePath(BaseAddress, string.Join('/', PathSections.Reverse()), "")); }
public string GetRelativePathString() { string pathString = "/"; if (PathSections != null && PathSections.Count > 0) { pathString += string.Join("/", PathSections.Reverse()); } return(pathString); }
public void ResetState(bool persistHeaders = false, bool persistPath = false) { BaseAddress = null; SwaggerEndpoint = null; if (!persistHeaders) { Headers.Clear(); AddDefaultHeaders(); } if (!persistPath) { PathSections.Clear(); } }
public Uri GetEffectivePath(string commandSpecifiedPath) { return(GetEffectivePath(BaseAddress, string.Join('/', PathSections.Reverse()), commandSpecifiedPath)); }
public Uri GetEffectivePath(IReadOnlyList <string> sections, bool requiresBody, out int filePathIndex) { filePathIndex = 1; if (BaseAddress == null) { return(null); } UriBuilder builder = new UriBuilder(BaseAddress); string path = string.Join('/', PathSections.Reverse()); string[] parts = path.Split('?'); string query = null; string query2 = null; if (parts.Length > 1) { path = parts[0]; query = string.Join('?', parts.Skip(1)); } builder.Path += path; if (sections.Count > 1) { if (!requiresBody || !File.Exists(sections[1])) { if (sections[1].Length > 0) { if (sections[1][0] != '/') { string argPath = sections[1]; if (builder.Path.Length > 0 && builder.Path[builder.Path.Length - 1] != '/') { argPath = "/" + argPath; } int queryIndex = argPath.IndexOf('?'); path = argPath; if (queryIndex > -1) { query2 = argPath.Substring(queryIndex + 1); path = argPath.Substring(0, queryIndex); } builder.Path += path; } else { int queryIndex = sections[1].IndexOf('?'); path = sections[1]; if (queryIndex > -1) { query2 = sections[1].Substring(queryIndex + 1); path = sections[1].Substring(0, queryIndex); } builder.Path = path; } } else { int queryIndex = sections[1].IndexOf('?'); path = sections[1]; if (queryIndex > -1) { query2 = sections[1].Substring(queryIndex + 1); path = sections[1].Substring(0, queryIndex); } builder.Path += path; } filePathIndex = 2; } } if (query != null) { if (!string.IsNullOrEmpty(builder.Query)) { query = "&" + query; } builder.Query += query; } if (query2 != null) { if (!string.IsNullOrEmpty(builder.Query)) { query2 = "&" + query2; } builder.Query += query2; } return(builder.Uri); }
public Uri GetEffectivePath(string commandSpecifiedPath) { if (Uri.TryCreate(commandSpecifiedPath, UriKind.Absolute, out Uri absoluteUri)) { return(absoluteUri); } UriBuilder builder = new UriBuilder(BaseAddress); string path = string.Join('/', PathSections.Reverse()); string[] parts = path.Split('?'); string query = null; string query2 = null; if (parts.Length > 1) { path = parts[0]; query = string.Join('?', parts.Skip(1)); } builder.Path += path; if (commandSpecifiedPath.Length > 0) { if (commandSpecifiedPath[0] != '/') { string argPath = commandSpecifiedPath; if (builder.Path.Length > 0 && builder.Path[builder.Path.Length - 1] != '/') { argPath = "/" + argPath; } int queryIndex = argPath.IndexOf('?'); path = argPath; if (queryIndex > -1) { query2 = argPath.Substring(queryIndex + 1); path = argPath.Substring(0, queryIndex); } builder.Path += path; } else { int queryIndex = commandSpecifiedPath.IndexOf('?'); path = commandSpecifiedPath; if (queryIndex > -1) { query2 = commandSpecifiedPath.Substring(queryIndex + 1); path = commandSpecifiedPath.Substring(0, queryIndex); } builder.Path = path; } } else { int queryIndex = commandSpecifiedPath.IndexOf('?'); path = commandSpecifiedPath; if (queryIndex > -1) { query2 = commandSpecifiedPath.Substring(queryIndex + 1); path = commandSpecifiedPath.Substring(0, queryIndex); } builder.Path += path; } if (query != null) { if (!string.IsNullOrEmpty(builder.Query)) { query = "&" + query; } builder.Query += query; } if (query2 != null) { if (!string.IsNullOrEmpty(builder.Query)) { query2 = "&" + query2; } builder.Query += query2; } return(builder.Uri); }