private static int BindParameter(APIClientParameterInfo argument, StringBuilder builder, Match match, int offset) { argument.IsHandled = false; var text = argument.Data != null ? Uri.EscapeUriString(ObjectFunctions.ToString(argument.Data)) : string.Empty; builder.Remove(offset + match.Index, match.Length); builder.Insert(offset + match.Index, text); return(offset += (text.Length - match.Length)); }
private static bool BindQuery(APIClientParameterInfo[] parameters, string url, StringBuilder builder) { var query = url.IndexOf('?') < 0; foreach (var argument in parameters) { if (argument.IsOptional) { argument.IsHandled = false; if (query) { query = false; builder.Append('?'); } else { builder.Append('&'); } builder.Append(argument.Name); if (argument.Data == null) { continue; } var text = Uri.EscapeDataString(ObjectFunctions.ToString(argument.Data)); builder.Append("="); builder.Append(text); } } return(query); }