changeset 29:e38192f55d2d

* 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
author IBBoard <dev@ibboard.co.uk>
date Sat, 11 Apr 2009 14:47:20 +0000
parents 41ddcd61dc92
children 23fd4247fc1c
files Collections/DictionaryUtils.cs IBBoard.csproj
diffstat 2 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
 		}
+		
+		/// <summary>
+		/// Convenience method to get a value from a dictionary for a given key. This method wraps a TryGetValue call in a single function.
+		/// </summary>
+		/// <param name="dictionary">
+		/// The <see cref="IDictionary"/> to get a value from
+		/// </param>
+		/// <param name="key">
+		/// The key to get the value for
+		/// </param>
+		/// <returns>
+		/// The value for <code>key</code>, or <code>null</code> if there was no value for the key
+		/// </returns>
+		public static VALUE_TYPE GetValue<KEY_TYPE, VALUE_TYPE>(IDictionary<KEY_TYPE, VALUE_TYPE> dictionary, KEY_TYPE key)
+		{
+			if (dictionary == null)
+			{
+				return default(VALUE_TYPE);
+			}
+			
+			VALUE_TYPE val = default(VALUE_TYPE);
+			dictionary.TryGetValue(key, out val);
+			return val;
+		}
 	}
 }
--- 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 @@
     <ProjectGuid>{5DFD64F6-FC2B-4B4F-B92E-483BAC468105}</ProjectGuid>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ApplicationIcon>
-    </ApplicationIcon>
     <AssemblyKeyContainerName>
     </AssemblyKeyContainerName>
     <AssemblyName>IBBoard</AssemblyName>
@@ -21,8 +19,6 @@
     <OutputType>Library</OutputType>
     <RootNamespace>IBBoard</RootNamespace>
     <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
-    <StartupObject>
-    </StartupObject>
     <FileUpgradeFlags>
     </FileUpgradeFlags>
     <UpgradeBackupLocation>
@@ -127,6 +123,7 @@
     <Compile Include="Collections\DictionaryUtils.cs" />
     <Compile Include="CustomMath\NumberParser.cs" />
     <Compile Include="Lang\TranslationLoadException.cs" />
+    <Compile Include="Xml\XmlTools.cs" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="libs\log4net.dll" />