Created
April 16, 2011 02:42
-
-
Save takeshik/922806 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Achiral.Make.Dictionary (modified) | |
/// <see>http://blogs.wankuma.com/mayuki/archive/2007/12/06/111901.aspx</see> | |
public static Dictionary<String, Object> Dictionary(params Expression<Func<Object, Object>>[] exprs) | |
{ | |
return exprs.ToDictionary(expr => expr.Parameters[0].Name, expr => expr.Compile().Invoke(null)); | |
} | |
var o = (IDictionary<String,Object>) new ExpandoObject(); | |
Dictionary(a => 123, b => "foo").ForEach(_ => o.Add(_.Key, _.Value)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment