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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -