private void RecourceParce(XNode xNode) { XElement currElement = (XElement)xNode; foreach (string findedName in Params.findedNames) { List <XElement> elements = currElement.Elements(findedName).ToList(); foreach (XElement xElem in elements) { xElem.Value = Params.ChangeName(xElem.Value); } } List <XNode> nodes = currElement.Nodes().ToList(); foreach (XNode currXNode in nodes) { //В случае, если не удалось распарсить строку currXNode в XElement - выходим из рекурсии. Значит добрались до глубины. try { XElement xElement = (XElement)currXNode; if (xElement.Nodes().Count() != 0) { RecourceParce(currXNode); } } catch { } } }
private void CleanSegments(UriBuilder uri) { string[] segments = uri.Path.Split('/'); for (int i = 0; i < segments.Length; i++) { if (String.IsNullOrEmpty(segments[i])) { continue; } foreach (string param in Params.findedNames) { if (segments[i].ToUpper() == param.ToUpper()) { if (i < segments.Length - 1) { segments[i + 1] = Params.ChangeName(segments[i + 1]); } } } } uri.Path = ""; foreach (string segment in segments) { if (!String.IsNullOrEmpty(segment)) { uri.Path += segment + '/'; } } uri.Path = uri.Path.Remove(uri.Path.Length - 1); }
private void RecourceFind(JToken host) { foreach (string findedName in Params.findedNames) { List <JToken> tokens = host.SelectTokens(findedName).ToList(); foreach (JToken token in tokens) { token.Replace(Params.ChangeName(token.Value <string>())); } } List <JToken> childrens = host.Children().ToList(); foreach (JToken currElem in childrens) { if (currElem.Children().ToList().Count != 0) { RecourceFind(currElem); } } }
private void CleanQuery(UriBuilder uri) { string[] queries = uri.Query.Split('&'); if (queries[0] == "") { return; } uri.Query = ""; foreach (string query in queries) { string[] paramStrings = query.Split('='); foreach (string paramName in Params.findedNames) { if (paramStrings[0].Trim('?') == paramName) { paramStrings[1] = Params.ChangeName(paramStrings[1]); } } uri.Query += paramStrings[0] + "=" + paramStrings[1] + "&"; } uri.Query = uri.Query.Remove(uri.Query.Length - 1); }