I wrote this function
private string BuildXPathQuery(string prefix = "descendant::", string tag = "*", object attrs = null)
{
StringBuilder sb = new StringBuilder(prefix);
sb.Append(tag);
if (attrs != null)
foreach (var a in attrs.GetType().GetProperties())
sb.Append(string.Format("[@{0}='{1}']", a.Name, a.GetValue(attrs, null)));
return sb.ToString();
}
So that instead of writing
BuildXPathQuery(attrs: new Dictionary<string,string> {{"attr","value"}});
I could write
BuildXPathQuery(attrs: new {attr=value});
But does this have any drawbacks?