<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>Comments on: Json adventures: Json.Net, DataContractJsonSerializer and a gun.</title>
	<atom:link href="https://www.altinet.hr/json-adventures-json-net-datacontractjsonserializer-and-a-gun/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.altinet.hr/json-adventures-json-net-datacontractjsonserializer-and-a-gun/</link>
	<description></description>
	<lastBuildDate>Wed, 19 May 2021 21:30:07 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.15</generator>
	<item>
		<title>By: evs</title>
		<link>https://www.altinet.hr/json-adventures-json-net-datacontractjsonserializer-and-a-gun/#comment-81</link>
		<dc:creator><![CDATA[evs]]></dc:creator>
		<pubDate>Mon, 27 Aug 2012 03:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.run80.net/?p=181#comment-81</guid>
		<description><![CDATA[This is quite nice.  I have adapted it a bit to suit my needs, the main thing I did was change the list of Known Types into a class, which is passed into the JsonKnownTypeConverter instead of a list of types. While doing this I&#039;ve also ensured the each known type is tied to its base type.

public class KnownTypeConfiguration : Dictionary&lt;Type, Dictionary&gt;
    {
        public void Add(Type baseType, string key, Type knownType)
        {
            if (!baseType.IsAssignableFrom(knownType))
            {
                throw new InvalidCastException();
            }

            if(!this.ContainsKey(baseType))
            {
                this.Add(baseType, new Dictionary());
            }

            this[baseType][key] = knownType;
        }

    }]]></description>
		<content:encoded><![CDATA[<p>This is quite nice.  I have adapted it a bit to suit my needs, the main thing I did was change the list of Known Types into a class, which is passed into the JsonKnownTypeConverter instead of a list of types. While doing this I&#8217;ve also ensured the each known type is tied to its base type.</p>
<p>public class KnownTypeConfiguration : Dictionary&lt;Type, Dictionary&gt;<br />
    {<br />
        public void Add(Type baseType, string key, Type knownType)<br />
        {<br />
            if (!baseType.IsAssignableFrom(knownType))<br />
            {<br />
                throw new InvalidCastException();<br />
            }</p>
<p>            if(!this.ContainsKey(baseType))<br />
            {<br />
                this.Add(baseType, new Dictionary());<br />
            }</p>
<p>            this[baseType][key] = knownType;<br />
        }</p>
<p>    }</p>
]]></content:encoded>
	</item>
</channel>
</rss>
