private bool ContainsHelper_IsExistsInInputUrl(string str) { if (this.IsInputURLHavingParam) { int indexOfQ = InputURL.IndexOf('?'); return(indexOfQ >= 0 && InputURL.Substring(indexOfQ).IndexOf(str, StringComparison.InvariantCultureIgnoreCase) >= 0); } return(false); }
public UrlGenerator RemoveAll() { KeyValueParams.Clear(); if (this.IsInputURLHavingParam) { int indexOfQ = InputURL.IndexOf('?'); if (indexOfQ >= 0) { InputURL = InputURL.Substring(0, indexOfQ); } } return(this); }
private void ConvertInputURL_ToParameters() { int indexOfQ = InputURL.IndexOf('?'); if (indexOfQ >= 0 && InputURL.Length > indexOfQ + 1) { string dummyURL = "http://localhost"; string newUrlString = InputURL; if (InputURL.StartsWith("~")) { newUrlString = InputURL.Remove(0, 1).Insert(0, dummyURL); //StringBuilder urlSbr = new StringBuilder(InputURL);urlSbr.Remove(0, 1);urlSbr.Insert(0, );newUrlString = urlSbr.ToString(); } else if (InputURL.StartsWith("/")) { newUrlString = InputURL.Insert(0, dummyURL); } else if (InputURL.StartsWith("?")) { newUrlString = InputURL.Insert(0, dummyURL + "/"); } else if (InputURL.IndexOf("//") < 0) { newUrlString = InputURL.Insert(0, dummyURL + "/"); } Uri myUri = new Uri(newUrlString); NameValueCollection nvc = HttpUtility.ParseQueryString(myUri.Query); string onlyURL = InputURL.Substring(0, indexOfQ); this.InputURL = onlyURL; //foreach (var keyItem in nvc.AllKeys) //{ this.KeyValueParams[keyItem] = nvc[keyItem]; } foreach (var keyItem in this.KeyValueParams.AllKeys) { nvc[keyItem] = this.KeyValueParams[keyItem]; } var tempList = this.KeyValueParams; this.KeyValueParams = nvc; tempList.Clear(); } }
public UrlGenerator AddIfKeyExists(string keyToCheck, string value) { if (KeyValueParams.AllKeys.Any(t => t.Equals(keyToCheck, StringComparison.InvariantCultureIgnoreCase))) { KeyValueParams[keyToCheck] = value; } if (this.IsInputURLHavingParam) { int indexOfQ = InputURL.IndexOf('?'); if (indexOfQ >= 0 && InputURL.Substring(indexOfQ).IndexOf(keyToCheck, StringComparison.InvariantCultureIgnoreCase) >= 0) { this.Remove(keyToCheck); KeyValueParams[keyToCheck] = value; } } return(this); }