String tag = "*", object attrs = null) {stringbirder sb = new stringbirder (prefix); Sb.Append (tag); If (attrs! = Null) foreach (ARR.GetType (). GetProperties ()) sb.Append (string.Format ("[@ {0} = '{1}']", a.Name, a gate value (Ethers, blank))); Return sb.ToString (); }
Instead of typing
BuildXPathQuery (ethers: new dictionary & lt; string, string & gt; {{"attr", "value"} });
I can write
BuildXPathQuery (attrs: new {attr = value});
But is there any drawbacks in this?
It uses reflection which can be slower than normal type of access, another drawback is By seeing that method signing, you see any object and for the last consumer of this method, it can not always be clear what should be kept as the object can really be anything:
When Intellisense shows:
BuildXPathQuery (object attrs);
You should actually be guessed here, as long as it is not very well documented (for example, ASP.NET MVC HTML Helpers have similar approaches to creating HTML properties on HTML elements. )
This is a very rivalistic approach that I like :-) (optional logic and hash tables)
Comments
Post a Comment