<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>PeteGoo's Blog</title>
        <link>http://blog.petegoo.com/Default.aspx</link>
        <description>.Net Heebie Jeebies</description>
        <language>en-NZ</language>
        <copyright>PeteGoo</copyright>
        <generator>Subtext Version 2.1.2.2</generator>
        <image>
            <title>PeteGoo's Blog</title>
            <url>http://blog.petegoo.com/images/RSS2Image.gif</url>
            <link>http://blog.petegoo.com/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Using JSON.Net to eval json into a dynamic variable in C#</title>
            <link>http://blog.petegoo.com/archive/2009/10/27/using-json.net-to-eval-json-into-a-dynamic-variable-in.aspx</link>
            <description>&lt;p&gt;So I thought this would be possible and finally decided to give it a shot in 2010 Beta 2. It turns a bunch of JSON into an &lt;a href="http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject(VS.100).aspx"&gt;ExpandoObject&lt;/a&gt; using &lt;a title="Json.Net" href="http://json.codeplex.com/"&gt;JSON.Net&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Needs cleaning up but not too bad.&lt;/p&gt;  &lt;div class="Section1"&gt;   &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;        [&lt;span style="color: #2b91af"&gt;TestMethod&lt;/span&gt;]&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; DeserializeTestObjectToDynamic(){&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;TestObject&lt;/span&gt; testObject = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestObject&lt;/span&gt;() {&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                FirstName = &lt;span style="color: #a31515"&gt;"Peter"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                LastName = &lt;span style="color: #a31515"&gt;"Goodman"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                DateOfBirth = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DateTime&lt;/span&gt;(&lt;span style="color: brown"&gt;1979&lt;/span&gt;, &lt;span style="color: brown"&gt;2&lt;/span&gt;, &lt;span style="color: brown"&gt;3&lt;/span&gt;),&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                Child = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestChildObject&lt;/span&gt; {&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line1 = &lt;span style="color: #a31515"&gt;"child line 1"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line2 = &lt;span style="color: #a31515"&gt;"child line 2"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line3 = &lt;span style="color: #a31515"&gt;"child line 3"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    City = &lt;span style="color: #a31515"&gt;"child city"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                },&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                Children = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Collection&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;TestChildObject&lt;/span&gt;&amp;gt;() {&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestChildObject&lt;/span&gt;() { &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line1 = &lt;span style="color: #a31515"&gt;"children 1 line 1"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line2 = &lt;span style="color: #a31515"&gt;"children 1 line 2"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line3 = &lt;span style="color: #a31515"&gt;"children 1 line 3"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    City = &lt;span style="color: #a31515"&gt;"children 1 city"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                },&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestChildObject&lt;/span&gt;() { &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line1 = &lt;span style="color: #a31515"&gt;"children 2 line 1"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line2 = &lt;span style="color: #a31515"&gt;"children 2 line 2"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    Line3 = &lt;span style="color: #a31515"&gt;"children 2 line 3"&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    City = &lt;span style="color: #a31515"&gt;"children 2 city"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                }&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                             }&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            };&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: green"&gt;// Get our json string &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: blue"&gt;string&lt;/span&gt; json = &lt;span style="color: #2b91af"&gt;JsonConvert&lt;/span&gt;.SerializeObject(testObject);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: green"&gt;// Create the json.Net Linq object for our json string&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;JObject&lt;/span&gt; jsonObject = &lt;span style="color: #2b91af"&gt;JObject&lt;/span&gt;.Parse(json);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: green"&gt;// eval into an expando&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: blue"&gt;dynamic&lt;/span&gt; dynObject = ConvertJTokenToObject(jsonObject);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.IsNotNull(dynObject);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.IsNotInstanceOfType(dynObject, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;TestObject&lt;/span&gt;));&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.IsInstanceOfType(dynObject, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;ExpandoObject&lt;/span&gt;));&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.FirstName, dynObject.FirstName);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.LastName, dynObject.LastName);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.DateOfBirth, dynObject.DateOfBirth);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.IsNotNull(dynObject.Child);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.Child.Line1, dynObject.Child.Line1);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.Child.Line2, dynObject.Child.Line2);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.Child.Line3, dynObject.Child.Line3);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.IsNotNull(dynObject.Children);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.Children.Count, dynObject.Children.Length);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: blue"&gt;for&lt;/span&gt; (&lt;span style="color: blue"&gt;int&lt;/span&gt; i = &lt;span style="color: brown"&gt;0&lt;/span&gt;; i &amp;lt; testObject.Children.Count; i++) {&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.Children[i].Line1, dynObject.Children[i].Line1);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.Children[i].Line2, dynObject.Children[i].Line2);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(testObject.Children[i].Line3, dynObject.Children[i].Line3);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            }&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;        }&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt; &lt;/p&gt; &lt;/div&gt;  &lt;div class="Section1"&gt;   &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;object&lt;/span&gt; ConvertJTokenToObject(&lt;span style="color: #2b91af"&gt;JToken&lt;/span&gt; token) {&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: blue"&gt;if&lt;/span&gt; (token &lt;span style="color: blue"&gt;is&lt;/span&gt; &lt;span style="color: #2b91af"&gt;JValue&lt;/span&gt;) { &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: blue"&gt;return&lt;/span&gt; ((&lt;span style="color: #2b91af"&gt;JValue&lt;/span&gt;)token).Value;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            }&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: blue"&gt;if&lt;/span&gt; (token &lt;span style="color: blue"&gt;is&lt;/span&gt; &lt;span style="color: #2b91af"&gt;JObject&lt;/span&gt;) { &lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: #2b91af"&gt;ExpandoObject&lt;/span&gt; expando = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ExpandoObject&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                (&lt;span style="color: blue"&gt;from&lt;/span&gt; childToken &lt;span style="color: blue"&gt;in&lt;/span&gt; ((&lt;span style="color: #2b91af"&gt;JToken&lt;/span&gt;)token) &lt;span style="color: blue"&gt;where&lt;/span&gt; childToken &lt;span style="color: blue"&gt;is&lt;/span&gt; &lt;span style="color: #2b91af"&gt;JProperty&lt;/span&gt; &lt;span style="color: blue"&gt;select&lt;/span&gt; childToken &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;JProperty&lt;/span&gt;).ToList().ForEach(property =&amp;gt; {&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    ((&lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;)expando).Add(property.Name, ConvertJTokenToObject(property.Value));&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                });&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: blue"&gt;return&lt;/span&gt; expando;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            }&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: blue"&gt;if&lt;/span&gt;(token &lt;span style="color: blue"&gt;is&lt;/span&gt; &lt;span style="color: #2b91af"&gt;JArray&lt;/span&gt;){&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: blue"&gt;object&lt;/span&gt;[] array = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: blue"&gt;object&lt;/span&gt;[((&lt;span style="color: #2b91af"&gt;JArray&lt;/span&gt;)token).Count];&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: blue"&gt;int&lt;/span&gt; index = &lt;span style="color: brown"&gt;0&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;JToken&lt;/span&gt; arrayItem &lt;span style="color: blue"&gt;in&lt;/span&gt; ((&lt;span style="color: #2b91af"&gt;JArray&lt;/span&gt;)token)) {&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    array[index] = ConvertJTokenToObject(arrayItem);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                    index++;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                }&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;                &lt;span style="color: blue"&gt;return&lt;/span&gt; array;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            }&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;            &lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"Unknown token type '{0}'"&lt;/span&gt;, token.GetType()), &lt;span style="color: #a31515"&gt;"token"&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt;        }&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"&gt;&lt;span style="font-family: consolas; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt; &lt;/p&gt; &lt;/div&gt;&lt;img src="http://blog.petegoo.com/aggbug/34.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2009/10/27/using-json.net-to-eval-json-into-a-dynamic-variable-in.aspx</guid>
            <pubDate>Tue, 27 Oct 2009 04:22:13 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/34.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2009/10/27/using-json.net-to-eval-json-into-a-dynamic-variable-in.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/34.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Unit Testing Visual Studio DSL Tools</title>
            <link>http://blog.petegoo.com/archive/2009/09/15/unit-testing-visual-studio-dsl-tools.aspx</link>
            <description>&lt;p&gt;I’ve been meaning to post this entry for a while now so while I wait for a 2010 beta install to complete…. &lt;/p&gt;  &lt;p&gt;For a long time I thought it wasn’t possible to unit test DSL Tools projects easily. Due to the nature of the environment it is sometimes difficult to see how unit testing is possible. The model elements are put in a partition in a store and all the partial classes, rules etc are very tightly coupled.&lt;/p&gt;  &lt;p&gt;It wasn’t until I wanted to write a use-case oriented management layer on top of our multiple DSLs that I first thought of how it was possible. I wanted to a find way to test that the abstracted co-ordination methods on the management layer would create the expected model elements and what I got was an accidental pattern for testing DSL tools.&lt;/p&gt;  &lt;p&gt;The main trick lies in creating a model context that will hold your store, model root and handle transactions.&lt;/p&gt;  &lt;p&gt;The ModelingTestContext class:&lt;/p&gt;  &lt;div style="font-family: courier new; background: white; color: black; font-size: 10pt"&gt;   &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ModelingTestContext&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;IDisposable&lt;/span&gt; {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;private&lt;/span&gt; Transaction tx;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;private&lt;/span&gt; Store store;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; ModelingTestContext() {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        store = &lt;span style="color: blue"&gt;new&lt;/span&gt; Store();&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt; domainModelType = &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(MyCompany.DomainModelDslDomainModel);&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: green"&gt;// Create a new store to deserialize the instance to. &lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;[] metaTypes = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;[]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;                               {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;                                   &lt;span style="color: blue"&gt;typeof&lt;/span&gt; (CoreDesignSurfaceDomainModel),&lt;/p&gt;    &lt;p style="margin: 0px"&gt;                                   domainModelType &lt;/p&gt;    &lt;p style="margin: 0px"&gt;                               };&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: green"&gt;// Load these types into the store, so that it knows about them for deserialization &lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        store.LoadDomainModels(metaTypes);&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        tx = store.TransactionManager.BeginTransaction(&lt;span style="color: #a31515"&gt;"Domain Modeling Test Context"&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        domainModelRoot = &lt;span style="color: blue"&gt;new&lt;/span&gt; MyModelRoot(store);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    }&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; MyModelRoot DomainModelRoot {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; domainModelRoot; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    }&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; Store Store {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; store; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    }&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; CommitChanges() {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        tx.Commit();&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        tx = store.TransactionManager.BeginTransaction(&lt;span style="color: #a31515"&gt;"Domain Modeling Test Context"&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    }&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Dispose() {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;if&lt;/span&gt;(tx != &lt;span style="color: blue"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; tx.IsActive) {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;            tx.Rollback();&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;}&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;This class will create the model root inside the store and manage transactions for us. We next need to start writing a test.&lt;/p&gt;  &lt;div style="font-family: courier new; background: white; color: black; font-size: 10pt"&gt;   &lt;p style="margin: 0px"&gt;[TestMethod]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; CreateAssociationSingleMultiplicity() {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;using&lt;/span&gt; (ModelingTestContext domainContext = &lt;span style="color: blue"&gt;new&lt;/span&gt; ModelingTestContext()) {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        domainContext.DomainModelRoot.Namespace = &lt;span style="color: #a31515"&gt;"Aderant.Test.DomainFoo"&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        DomainComponent clientDc = domainContext.CreateDomainComponent(&lt;span style="color: #a31515"&gt;"Client"&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        DomainComponent addressDc = domainContext.CreateDomainComponent(&lt;span style="color: #a31515"&gt;"Address"&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        AssociationLink link = clientDc.AssociateWith(addressDc, Multiplicity.One);&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        domainContext.CommitChanges();&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        Assert.AreEqual(addressDc.Name, link.TargetRoleName);&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;    }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;}&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;We create a context inside a using block so that we can clean up the transaction when the test completes. In this test I have added extension methods to the domain context and the DomainComponent class to support the common scenarios I used in testing like &lt;em&gt;CreateDomainComponent &lt;/em&gt;and &lt;em&gt;AssociationWith&lt;/em&gt;, allowing me to encapsulate common behavior. These extension methods can then be moved to become behavior of the model or the management API. Therefore over time you provide better API functionality which is tested.&lt;/p&gt;  &lt;p&gt;Now some people would call this integration testing instead of unit testing…..fair enough. Also some would say that the extension methods and the test context for that matter are making the tests brittle as DRY does not apply to unit testing, I would disagree as otherwise these tests would become unmanageable.&lt;/p&gt;  &lt;p&gt;I hope you find this useful.&lt;/p&gt;  &lt;p&gt;Pete&lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/33.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2009/09/15/unit-testing-visual-studio-dsl-tools.aspx</guid>
            <pubDate>Mon, 14 Sep 2009 21:18:17 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/33.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2009/09/15/unit-testing-visual-studio-dsl-tools.aspx#feedback</comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/33.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Don&amp;rsquo;t try to explain geek jokes to your partner</title>
            <link>http://blog.petegoo.com/archive/2009/05/11/donrsquot-try-to-explain-geek-jokes-to-your-partner.aspx</link>
            <description>&lt;p&gt;&lt;img src="http://imgs.xkcd.com/comics/exploits_of_a_mom.png" /&gt; &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;I tried to explain the humour in this joke to my girlfriend. I was laughing too hard at the time, partly at the joke, partly at the fact I was trying to explain it to her. Don’t try this at home, it may make you a very lonely person.&lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/32.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2009/05/11/donrsquot-try-to-explain-geek-jokes-to-your-partner.aspx</guid>
            <pubDate>Sun, 10 May 2009 21:16:56 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/32.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2009/05/11/donrsquot-try-to-explain-geek-jokes-to-your-partner.aspx#feedback</comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/32.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Shizxaml &amp;ndash; Silverlight&amp;rsquo;s old codename?</title>
            <link>http://blog.petegoo.com/archive/2009/03/24/shizxaml-ndash-silverlightrsquos-old-codename.aspx</link>
            <description>&lt;p&gt;According to &lt;a title="Mike Harsh blog" href="http://blogs.msdn.com/mharsh/" target="_blank"&gt;Mike Harsh&lt;/a&gt; in his Mix talk on &lt;a href="http://videos.visitmix.com/MIX09/T45F" target="_blank"&gt;Silverlight 3.0 – Out of Browser&lt;/a&gt;, before silverlight was WPF/E, internally Microsoft were calling it &lt;strong&gt;&lt;em&gt;Shizxaml&lt;/em&gt;&lt;/strong&gt;. I so wish this had been the product name. “Lets shizxaml that sucker” and the like. Brilliant!&lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/31.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2009/03/24/shizxaml-ndash-silverlightrsquos-old-codename.aspx</guid>
            <pubDate>Tue, 24 Mar 2009 01:04:43 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/31.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2009/03/24/shizxaml-ndash-silverlightrsquos-old-codename.aspx#feedback</comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/31.aspx</wfw:commentRss>
        </item>
        <item>
            <title>DataContractJsonSerializer and DateTime values</title>
            <link>http://blog.petegoo.com/archive/2009/03/17/datacontractjsonserializer-and-datetime-values.aspx</link>
            <description>&lt;p&gt;In using the &lt;a title="MSDN DataContractJsonSerializer" href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx" target="_blank"&gt;DataContractJsonSerializer&lt;/a&gt; beware of &lt;a href="http://msdn.microsoft.com/en-us/library/bb412170.aspx#" target="_blank"&gt;DateTime instances&lt;/a&gt; which have been instantiated as non-UTC. If you declare without explicitly assigning a DateTime you get the same as &lt;em&gt;default(DateTime)&lt;/em&gt;, this is 01/01/01 00:00:00 (0 ticks) with a DateTimeKind of &lt;em&gt;Unspecified&lt;/em&gt;. When the DataContractJsonSerializer looks at this value (or a Local datetime), it will try to convert it to UTC by subtracting the time zone ala UTC standard notation, this results in a date time that is less that 0 ticks and an out of range exception if you are west of GMT.&lt;/p&gt;  &lt;p&gt;The solution is to always instantiate as UTC and you can avoid this issue. As &lt;a href="http://blog.petegoo.com/archive/2009/03/17/wcf-collections-with-payload-via-surrogates.aspx" target="_blank"&gt;mentioned previously&lt;/a&gt; you cannot interrupt the serialization process for DateTime on a member of the DataContract serializer family.&lt;/p&gt;  &lt;p&gt;Another pain in the rectum is that it will change the accuracy of your DateTime value from 100 ns to 1 ms, so if you are relying on this value being the same for change tracking or any other means then this will produce problems.&lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/30.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2009/03/17/datacontractjsonserializer-and-datetime-values.aspx</guid>
            <pubDate>Mon, 16 Mar 2009 23:13:36 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/30.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2009/03/17/datacontractjsonserializer-and-datetime-values.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/30.aspx</wfw:commentRss>
        </item>
        <item>
            <title>WCF Collections with Payload via Surrogates</title>
            <link>http://blog.petegoo.com/archive/2009/03/17/wcf-collections-with-payload-via-surrogates.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://blog.petegoo.com/archive/2007/10/31/wcf-custom-collections-with-extra-payload.aspx" target="_blank"&gt;Previously&lt;/a&gt; I posted about the problem with WCF and collection which have a payload in them. I came across this problem again when using the DataContractJsonSerializer and thought I would look at possibilities to resolve it.&lt;/p&gt;  &lt;p&gt;If you have implemented the IXmlSerializable interface then you are kind of stuffed because the Json serializer will emit json with a bunch of xml in the middle….nice! It is really useful to reference &lt;a href="http://blogs.msdn.com/sowmy/archive/2006/02/22/536747.aspx" target="_blank"&gt;sowmy’s post&lt;/a&gt; on the precedence of serializable classes in the Data Contract family of serializers.&lt;/p&gt;  &lt;p&gt;Instead you can use a Surrogate. This is a class which implements &lt;a title="IDataContractSurrogate on MSDN" href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.idatacontractsurrogate.aspx" target="_blank"&gt;IDataContractSurrogate&lt;/a&gt; and can be passed to the constructor of the serializer. It tells the serializer that when you come to serialize type &lt;strong&gt;&lt;em&gt;x&lt;/em&gt;&lt;/strong&gt;, instead use type &lt;strong&gt;&lt;em&gt;y&lt;/em&gt;&lt;/strong&gt; and I will give you the converted instance. At the other end the class gets deserialized into the original type and all is good. &lt;/p&gt;  &lt;p&gt;For our custom collection with payload this works great. It will &lt;strong&gt;not&lt;/strong&gt; however work with CLR types like DateTime, the precedence of WCF serialization kicks in before the surrogate provider is queried for a transmission type.&lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/29.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2009/03/17/wcf-collections-with-payload-via-surrogates.aspx</guid>
            <pubDate>Mon, 16 Mar 2009 23:01:30 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/29.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2009/03/17/wcf-collections-with-payload-via-surrogates.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/29.aspx</wfw:commentRss>
        </item>
        <item>
            <title>MS-Test DeploymentItem Attribute........Aaaaaaaagh!</title>
            <link>http://blog.petegoo.com/archive/2009/01/22/ms-test-deploymentitem-attribute.aaaaaaaagh.aspx</link>
            <description>&lt;p&gt;We have a policy of using MS-Test, although that is overdue for a serious review.&lt;/p&gt;  &lt;p&gt;So it turns out you can use the deployment item attribute.... &lt;/p&gt;  &lt;p style="background: white; margin: 0cm 0cm 0pt"&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;[&lt;/span&gt;&lt;span style="font-size: 10pt; color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;"&gt;TestMethod&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;] &lt;/span&gt;&lt;/p&gt;  &lt;p style="background: white; margin: 0cm 0cm 0pt"&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;[&lt;/span&gt;&lt;span style="font-size: 10pt; color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;"&gt;DeploymentItem&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;"UnitTest.MyProject.TestData.xml"&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;)] &lt;/span&gt;&lt;/p&gt;  &lt;p style="background: white; margin: 0cm 0cm 0pt"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;void&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt; GetAllStatuses() {...} &lt;/span&gt;&lt;/p&gt;  &lt;p /&gt;  &lt;p&gt;....As long as you don’t provide a constant... &lt;/p&gt;  &lt;p /&gt;  &lt;p style="background: white; margin: 0cm 0cm 0pt"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;const&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;string&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt; XMLCONFIGFILE = &lt;/span&gt;&lt;span style="font-size: 10pt; color: #a31515; font-family: &amp;quot;Courier New&amp;quot;"&gt;"UnitTest.MyProject.TestData.xml"&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;; &lt;/span&gt;&lt;/p&gt;  &lt;p /&gt;  &lt;p style="background: white; margin: 0cm 0cm 0pt"&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;[&lt;/span&gt;&lt;span style="font-size: 10pt; color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;"&gt;TestMethod&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;] &lt;/span&gt;&lt;/p&gt;  &lt;p style="background: white; margin: 0cm 0cm 0pt"&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;[&lt;/span&gt;&lt;span style="font-size: 10pt; color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;"&gt;DeploymentItem&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;"&gt;TestHelper&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt;.XMLCONFIGFILE)] &lt;/span&gt;&lt;/p&gt;  &lt;p style="background: white; margin: 0cm 0cm 0pt"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;"&gt;void&lt;/span&gt;&lt;span style="font-size: 10pt; color: black; font-family: &amp;quot;Courier New&amp;quot;"&gt; GetAllStatuses() {...} &lt;/span&gt;&lt;/p&gt;  &lt;p /&gt;  &lt;p&gt;It just ignores it.....Genius! Now my tests have to be littered with this string literal. &lt;/p&gt;  &lt;p&gt;Makes you wonder how they are implementing this stuff. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;Pete &lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/28.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2009/01/22/ms-test-deploymentitem-attribute.aaaaaaaagh.aspx</guid>
            <pubDate>Thu, 22 Jan 2009 00:05:01 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/28.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2009/01/22/ms-test-deploymentitem-attribute.aaaaaaaagh.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/28.aspx</wfw:commentRss>
        </item>
        <item>
            <title>C# var - with great power comes great responsibility</title>
            <link>http://blog.petegoo.com/archive/2008/12/10/c-var-with-great-power-comes-great-responsibility.aspx</link>
            <description>&lt;p&gt;There are many heated discussions on the overuse of var and I'm not going to repeat the arguments here. Personally, I have no problem with var used in the declaration of a variable where the value is instantiated inline via a constructor, anything else (apart from LINQ) seems dangerous. Having said that, the following sample I came across today is simply stupid.&lt;/p&gt;  &lt;p&gt;var controller = new MyController().GetValueX(foo);&lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/27.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2008/12/10/c-var-with-great-power-comes-great-responsibility.aspx</guid>
            <pubDate>Tue, 09 Dec 2008 23:51:40 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/27.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2008/12/10/c-var-with-great-power-comes-great-responsibility.aspx#feedback</comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/27.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Preview Handlers for Vista and Outlook 2007</title>
            <category>Main Page</category>
            <category>Productivity</category>
            <link>http://blog.petegoo.com/archive/2008/12/10/preview-handlers-for-vista-and-outlook-2007.aspx</link>
            <description>&lt;p&gt;Really useful for those xml files that people send you.&lt;/p&gt;  &lt;p&gt;Download the &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163487.aspx" target="_blank"&gt;MSDN Magazine Preview Handlers&lt;/a&gt; and then setup the xml file with &lt;a href="http://blogs.msdn.com/toub/archive/2006/12/14/preview-handler-association-editor.aspx" target="_blank"&gt;this really cool utility&lt;/a&gt;. It gives explorer and outlook preview capabilities for all sorts of file types.&lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/26.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2008/12/10/preview-handlers-for-vista-and-outlook-2007.aspx</guid>
            <pubDate>Tue, 09 Dec 2008 23:46:56 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/26.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2008/12/10/preview-handlers-for-vista-and-outlook-2007.aspx#feedback</comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/26.aspx</wfw:commentRss>
        </item>
        <item>
            <title>DSL Tools in Visual Studio 2010</title>
            <link>http://blog.petegoo.com/archive/2008/11/10/dsl-tools-in-visual-studio-2010.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/stuart_kent" target="_blank"&gt;Stuart Kent&lt;/a&gt; has &lt;a href="http://blogs.msdn.com/stuart_kent/archive/2008/11/05/dsl-tools-in-visual-studio-2010.aspx" target="_blank"&gt;blogged about&lt;/a&gt; the new features they are planning for DSL Tools in the Visual Studio 2010 timeframe. Of particular interest are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Dsl extensibility&lt;/strong&gt;. Extend the domain model and behavior for a DSL after it's been deployed, including DSLs shipped by a third party.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Readonly&lt;/strong&gt;. Selectively switch off the ability to edit models and model elements in a designer.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Forms-based UI&lt;/strong&gt;. Easily bind models to winforms and WPF-based forms UI. IMS now implements the necessary databinding interfaces.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Modelbus&lt;/strong&gt;. A new piece of platform to support cross-referencing between models and interaction between designers. This has been one of customers' main requests. This one kind of blows my &lt;a href="http://www.codeplex.com/DslCrossModel" target="_blank"&gt;codeplex&lt;/a&gt; project out of the water, which is probably a good thing as I can't find the time to finish it.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;T4 precompile&lt;/strong&gt;. Precompile text templates so that they can be deployed for use on machines that do not have VS installed.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Also of interest are the various blog entries on the overlap between DSL and Oslo from &lt;a href="http://blogs.msdn.com/stuart_kent/archive/2008/11/07/dsl-tools-and-oslo.aspx" target="_blank"&gt;Stuart Kent&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/keith_short/archive/2008/11/06/oslo-and-the-dsl-toolkit.aspx" target="_blank"&gt;Keith Short&lt;/a&gt;. Personally I think Oslo is a huge step forward for Model-Driven architectures and shows a willingness to provide something useful for developers which does more than simply expand the already disparate tooling.&lt;/p&gt;&lt;img src="http://blog.petegoo.com/aggbug/25.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>PeteGoo</dc:creator>
            <guid>http://blog.petegoo.com/archive/2008/11/10/dsl-tools-in-visual-studio-2010.aspx</guid>
            <pubDate>Sun, 09 Nov 2008 19:49:31 GMT</pubDate>
            <wfw:comment>http://blog.petegoo.com/comments/25.aspx</wfw:comment>
            <comments>http://blog.petegoo.com/archive/2008/11/10/dsl-tools-in-visual-studio-2010.aspx#feedback</comments>
            <wfw:commentRss>http://blog.petegoo.com/comments/commentRss/25.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>