<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Presenting WeakDictionary[TKey, TValue]</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx</link><description>This morning, I posted a base class to assist with implementing IDictionary&amp;lt;TKey,TValue&amp;gt;. As I mentioned this was just the first chunk of work required as part of my goal of building a generic dictionary which uses weak references for its keys and</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Fiberglass flowers / Questions on .NET I don&amp;#8217;t expect answers to</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#7185997</link><pubDate>Mon, 21 Jan 2008 20:14:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7185997</guid><dc:creator>Fiberglass flowers / Questions on .NET I don’t expect answers to</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://victorsergienko.com/dotnet-cannot-answer/"&gt;http://victorsergienko.com/dotnet-cannot-answer/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Presenting WeakDictionary[TKey, TValue]</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#7676850</link><pubDate>Wed, 13 Feb 2008 19:01:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7676850</guid><dc:creator>Victor Sergienko</dc:creator><description>&lt;p&gt;Is it OK that ContainsKey() returns true for collected objects?&lt;/p&gt;
&lt;p&gt;I updated ContainsKey() this way:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public override bool ContainsKey(TKey key)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return this.dictionary.ContainsKey(key);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (!this.dictionary.ContainsKey(key)) return false;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;WeakReference&amp;lt;TValue&amp;gt; weakValue;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return (this.dictionary.TryGetValue(key, out weakValue));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
</description></item><item><title>re: Presenting WeakDictionary[TKey, TValue]</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#8129044</link><pubDate>Mon, 10 Mar 2008 12:20:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8129044</guid><dc:creator>Dan</dc:creator><description>&lt;p&gt;Not sure what the use would be, having it use WeakReference for both key and value means you have to keep track of both key and value elsewhere, so why would I bother with using this class then?&lt;/p&gt;
&lt;p&gt;The use I've had (in Java) for a WeakDictionary was as a cheap cache, when I drop the key it will automatically clear out the value, but as long as I hold on to the key its likely the value will be kept.&lt;/p&gt;
&lt;p&gt;I'd also like to question why you feel the need to use internal on the helper classes? If they are so specific that they only have a use for your WeakDictionary class then they should be private under the WeakDictionary, and if you want to be able to use them in more places then public is a terrific way of making sure they are useable where they are needed.&lt;/p&gt;
</description></item><item><title>re: Presenting WeakDictionary[TKey, TValue]</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#8351951</link><pubDate>Wed, 02 Apr 2008 20:35:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8351951</guid><dc:creator>Logan Murray</dc:creator><description>&lt;p&gt;Wow this looks a quite impressive bit of engineering.&lt;/p&gt;
&lt;p&gt;I just have a couple comments:&lt;/p&gt;
&lt;p&gt;First of all, (I only skimmed the code) you mention that both the key and the value are weak references. This means that the value must also be referenced elsewhere for it to stay alive... you can't just add a new reference to the dictionary. I assume this is by design. For my purposes, however, I need a dictionary that only has weak keys (not values) because I use the dictionary primarily as a datastore. My point in mentioning this is you might be clear on that point because it's rather important to the use of this in a particular design.&lt;/p&gt;
&lt;p&gt;Secondly, is not:&lt;/p&gt;
&lt;p&gt;&amp;quot;new WeakReference( someObject ) == new WeakReference( someObject )&amp;quot; true?&lt;/p&gt;
&lt;p&gt;Why the need for such a complex weak key comparer? Or is this specifically so you can compare weak references to strong references and live ones to dead ones and so forth (though when you think about it you can't really have a live reference and a dead reference pointing to the same object can you? I guess that's why you always return false in this instance).&lt;/p&gt;
&lt;p&gt;That said, good work. It's nice to see some advanced .NET coding that really pushes the limits of the framework. ;)&lt;/p&gt;
</description></item><item><title>
  Caliburn Alpha fuer WPF und Silverlight</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#8997327</link><pubDate>Mon, 13 Oct 2008 07:54:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8997327</guid><dc:creator>
  Caliburn Alpha fuer WPF und Silverlight</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.silverlight-travel.com/blog/2008/10/13/caliburn-alpha-fuer-wpf-und-silverlight/"&gt;http://www.silverlight-travel.com/blog/2008/10/13/caliburn-alpha-fuer-wpf-und-silverlight/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Presenting WeakDictionary[TKey, TValue]</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#9448811</link><pubDate>Fri, 27 Feb 2009 17:08:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9448811</guid><dc:creator>Andy Kutruff</dc:creator><description>&lt;p&gt;Amazing work. &amp;nbsp;Just as an FYI, I'm adding this to Continuous LINQ for managing our weak event cache. &amp;nbsp;&lt;/p&gt;
</description></item><item><title>High Performance Property Changed Weak Event Notifications for C# &amp;laquo; Andy Kutruff</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#9463507</link><pubDate>Sat, 07 Mar 2009 00:58:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9463507</guid><dc:creator>High Performance Property Changed Weak Event Notifications for C# &amp;laquo; Andy Kutruff</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://kutruff.wordpress.com/2009/03/06/high-performance-property-changed-weak-event-notifications-for-c/"&gt;http://kutruff.wordpress.com/2009/03/06/high-performance-property-changed-weak-event-notifications-for-c/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Nick Guerrera s blog Presenting WeakDictionary TKey TValue | pool toys</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#9774394</link><pubDate>Thu, 18 Jun 2009 11:45:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9774394</guid><dc:creator> Nick Guerrera s blog Presenting WeakDictionary TKey TValue | pool toys</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://pooltoysite.info/story.php?id=3389"&gt;http://pooltoysite.info/story.php?id=3389&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Presenting WeakDictionary[TKey, TValue]</title><link>http://blogs.msdn.com/nicholg/archive/2006/06/04/617466.aspx#9896224</link><pubDate>Thu, 17 Sep 2009 11:12:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9896224</guid><dc:creator>chha</dc:creator><description>&lt;p&gt;Thanks for the code, is exactly what I was already looking for many times. I removed the constraints &lt;/p&gt;
&lt;p&gt;where TKey : class&lt;/p&gt;
&lt;p&gt;where TValue : class&lt;/p&gt;
&lt;p&gt;as I often also reference native objects like Int32 etc. although it needs somewhere double-casting in C# (in VB it would need only a single cast, but when I was looking at the effort to translate the &amp;quot;yield&amp;quot; statement, I decided to stay with C# this time...)&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;chha&lt;/p&gt;
</description></item></channel></rss>