quartz.net - Pass a C# dynamic object to a method that takes an IDictionary -
right now, i'm doing this
var data = new jobdatamap(new dictionary<string,string> { {"obj", "stringify"} });
but want this:
dynamic d = new { obj = "stringify" }; var data = new jobdatamap(d);
is there secret syntactical sugar allow me this?
there's no magical way of doing this. there's no way compiler can know dynamic object dictionary @ compile time.
that being said, create extension method converts dictionary this:
dynamic d = new { obj = "stringify" }; var data = new jobdatamap(d.todictionary());
this blogpost offers example: http://blog.andreloker.de/post/2008/05/03/anonymous-type-to-dictionary-using-dynamicmethod.aspx
Comments
Post a Comment