<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Using C# 3.0 Anonymous Types as Dictionaries</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx</link><description>During a design meeting for a new feature in ASP.NET we had a requirement that a new method accept a dictionary of name/values pairs. An obvious solution is to have the method accept a parameter of type IDictionary (or its generic cousin): public static</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Lambda Abuse? &amp;laquo; Tales from a Trading Desk</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#7291075</link><pubDate>Fri, 25 Dec 2009 20:06:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7291075</guid><dc:creator>Lambda Abuse? « Tales from a Trading Desk</dc:creator><author>Lambda Abuse? « Tales from a Trading Desk</author><description>&lt;p&gt;Pingback from &amp;nbsp;Lambda Abuse? &amp;amp;laquo; Tales from a Trading Desk&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7291075" width="1" height="1"&gt;</description></item><item><title>[转自scott]ASP.NET MVC框架 (第二部分): URL路径选择</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#7120377</link><pubDate>Sat, 13 Jun 2009 12:37:33 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7120377</guid><dc:creator>菩提树下的杨过</dc:creator><author>菩提树下的杨过</author><description>&lt;p&gt;英文原文地址:&lt;a rel="nofollow" target="_new" href="http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.as"&gt;weblogs.asp.net/.../asp-net-mvc-framework-part-2-url-routing.as&lt;/a&gt;...&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7120377" width="1" height="1"&gt;</description></item><item><title>【转】Scott_ASP.NET MVC框架(第二部分) URL路径选择</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#6952127</link><pubDate>Tue, 10 Mar 2009 06:37:08 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6952127</guid><dc:creator>青羽</dc:creator><author>青羽</author><description>&lt;p&gt;Scott_ASP.NET MVC框架(第二部分) URL路径选择&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6952127" width="1" height="1"&gt;</description></item><item><title>ASP.NET MVC Archived Buzz, Page 1</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#6768706</link><pubDate>Sat, 06 Dec 2008 22:05:19 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6768706</guid><dc:creator>ASP.NET MVC Archived Buzz, Page 1</dc:creator><author>ASP.NET MVC Archived Buzz, Page 1</author><description>&lt;p&gt;Pingback from &amp;nbsp;ASP.NET MVC Archived Buzz, Page 1&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6768706" width="1" height="1"&gt;</description></item><item><title>Jay R. Wren - lazy dawg evarlast  &amp;raquo; Blog Archive   &amp;raquo; Dr. Strange HoH: How I Learned To Love Perl and C#</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#6713111</link><pubDate>Thu, 30 Oct 2008 23:45:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6713111</guid><dc:creator>Jay R. Wren - lazy dawg evarlast  » Blog Archive   » Dr. Strange HoH: How I Learned To Love Perl and C#</dc:creator><author>Jay R. Wren - lazy dawg evarlast  » Blog Archive   » Dr. Strange HoH: How I Learned To Love Perl and C#</author><description>&lt;p&gt;Pingback from &amp;nbsp;Jay R. Wren - lazy dawg evarlast &amp;nbsp;&amp;amp;raquo; Blog Archive &amp;nbsp; &amp;amp;raquo; Dr. Strange HoH: How I Learned To Love Perl and C#&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6713111" width="1" height="1"&gt;</description></item><item><title>re: Using C# 3.0 Anonymous Types as Dictionaries</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#6663010</link><pubDate>Tue, 07 Oct 2008 16:57:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6663010</guid><dc:creator>David</dc:creator><author>David</author><description>&lt;p&gt;I&amp;#39;ve become accustomed to this JSON style syntax using jQuery and often wish that C# offered something similar. &amp;nbsp;However I agree with others that stated they still want the advantages of static typing. &amp;nbsp;Seems to me you would get the best of both worlds if C# provided a more succinct dictionary initializer and better type inference. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;string GetUrl(string baseUrl, Dictionary&amp;lt;string, string&amp;gt; parameters);&lt;/p&gt;
&lt;p&gt;I want to do this:&lt;/p&gt;
&lt;p&gt;HtmlHelpers.GetUrl(&amp;quot;&lt;a rel="nofollow" target="_new" href="http://www.example.org/search&amp;quot;"&gt;www.example.org/search&amp;quot;&lt;/a&gt;, new(){ &amp;quot;query&amp;quot; = &amp;quot;kitten&amp;#39;s mittens&amp;quot;, &amp;quot;mode&amp;quot; = &amp;quot;details&amp;quot; });&lt;/p&gt;
&lt;p&gt;Not this (yuck):&lt;/p&gt;
&lt;p&gt;HtmlHelpers.GetUrl(&amp;quot;&lt;a rel="nofollow" target="_new" href="http://www.example.org/search&amp;quot;"&gt;www.example.org/search&amp;quot;&lt;/a&gt;, new Dictionary&amp;lt;string,string&amp;gt; { {&amp;quot;query&amp;quot;, &amp;quot;kitten&amp;#39;s mittens&amp;quot;}, {&amp;quot;mode&amp;quot;, &amp;nbsp;&amp;quot;details&amp;quot;}});&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6663010" width="1" height="1"&gt;</description></item><item><title>re: Using C# 3.0 Anonymous Types as Dictionaries</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#6646213</link><pubDate>Mon, 29 Sep 2008 02:30:39 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6646213</guid><dc:creator>Eilon</dc:creator><author>Eilon</author><description>&lt;p&gt;Steve -&lt;/p&gt;
&lt;p&gt;You can use RouteValueDictionary's constructor to automatically &amp;quot;parse out&amp;quot; the properties and their values. If you want to see exactly how it's done just use Reflector on it and rip off the source code :)&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Eilon&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6646213" width="1" height="1"&gt;</description></item><item><title>re: Using C# 3.0 Anonymous Types as Dictionaries</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#6644274</link><pubDate>Sat, 27 Sep 2008 14:07:48 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6644274</guid><dc:creator>Steve</dc:creator><author>Steve</author><description>&lt;p&gt;How do you parse out the object to get the values?&lt;/p&gt;
&lt;p&gt;ie.&lt;/p&gt;
&lt;p&gt;new{ height=10, width=20}&lt;/p&gt;
&lt;p&gt;TextBox takes an object htmlAttributes&lt;/p&gt;
&lt;p&gt;I dont know how to take some object like this and pull the values out to pass it to the TextBox object.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6644274" width="1" height="1"&gt;</description></item><item><title>re: Using C# 3.0 Anonymous Types as Dictionaries</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#6220443</link><pubDate>Sun, 25 May 2008 18:53:03 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6220443</guid><dc:creator>Stormy</dc:creator><author>Stormy</author><description>&lt;p&gt;All these arguments are moot really, about the value of anonymous types, etc.&lt;/p&gt;
&lt;p&gt;You should NEVER build a web application that has its markup tags and attributes generated &amp;nbsp;via dependencies in backend code like this. The whole point of CSS/XHTML and the whole Web Standards movement is to get away from the whole concept of generating HTML in the backend and separation of business logic from the UI layer. This reminds me of the messy html used in ASP.NET 1.1. The HTML Helpers are also breaking this separation in that model.&lt;/p&gt;
&lt;p&gt;What you should do is have a static web page with anchor tags and a full set of attributes with default values assigned. This allows UI designers control over the interface design. When it comes time to manipulate the attributes of these tags, the backend should pass in the control and change attributes as properties on that control like ASP.NET does now with HTML Server Controls, not dynamically generate these links in the backend.&lt;/p&gt;
&lt;p&gt;What happens if the UI designer does NOT want that anchor displayed, or wants to customize it via JavaScript, or expects to pull in additional attributes or databinding to those attributes? This model would have to be retooled. I say, all of you need to go back to school and relearn basic HTML 101.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6220443" width="1" height="1"&gt;</description></item><item><title>re: Using C# 3.0 Anonymous Types as Dictionaries</title><link>http://weblogs.asp.net/leftslipper/archive/2007/09/24/using-c-3-0-anonymous-types-as-dictionaries.aspx#6121871</link><pubDate>Tue, 22 Apr 2008 19:54:51 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6121871</guid><dc:creator>aaron</dc:creator><author>aaron</author><description>&lt;p&gt;For those of you complaining about not wanting any dynamically influenced language features in your code: don&amp;#39;t use them. For everyone else, Rejoice!&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6121871" width="1" height="1"&gt;</description></item></channel></rss>