# HG changeset patch # User IBBoard # Date 1239461240 0 # Node ID e38192f55d2de2a5071a57678cb5e7993cce0fe6 # Parent 41ddcd61dc92776be46640f5fd1ad30022caeddb * Add convenience method to get a value from a dictionary in a single line * Commit .csproj file to include XMLTools in project no-open-ticket diff -r 41ddcd61dc92 -r e38192f55d2d Collections/DictionaryUtils.cs --- a/Collections/DictionaryUtils.cs Thu Apr 09 15:10:51 2009 +0000 +++ b/Collections/DictionaryUtils.cs Sat Apr 11 14:47:20 2009 +0000 @@ -89,5 +89,29 @@ return mergedDictionary; } + + /// + /// Convenience method to get a value from a dictionary for a given key. This method wraps a TryGetValue call in a single function. + /// + /// + /// The to get a value from + /// + /// + /// The key to get the value for + /// + /// + /// The value for key, or null if there was no value for the key + /// + public static VALUE_TYPE GetValue(IDictionary dictionary, KEY_TYPE key) + { + if (dictionary == null) + { + return default(VALUE_TYPE); + } + + VALUE_TYPE val = default(VALUE_TYPE); + dictionary.TryGetValue(key, out val); + return val; + } } } diff -r 41ddcd61dc92 -r e38192f55d2d IBBoard.csproj --- a/IBBoard.csproj Thu Apr 09 15:10:51 2009 +0000 +++ b/IBBoard.csproj Sat Apr 11 14:47:20 2009 +0000 @@ -7,8 +7,6 @@ {5DFD64F6-FC2B-4B4F-B92E-483BAC468105} Debug AnyCPU - - IBBoard @@ -21,8 +19,6 @@ Library IBBoard OnBuildSuccess - - @@ -127,6 +123,7 @@ +