changeset 12:465b672e9682

Closes #5 - Dictionary to array converter * Handled null dictionary * Fixed casting problems * Added documentation Also remove rogue Console.Write in LogNotifier
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Jan 2009 18:45:32 +0000
parents ba9239164de2
children 6b762694f051
files Collections/DictionaryToArrayConverter.cs Logging/LogNotifier.cs
diffstat 2 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Collections/DictionaryToArrayConverter.cs	Sun Jan 04 14:44:19 2009 +0000
+++ b/Collections/DictionaryToArrayConverter.cs	Sun Jan 04 18:45:32 2009 +0000
@@ -25,11 +25,25 @@
 	
 	public class DictionaryToArrayConverter
 	{
+		/// <summary>
+		/// Takes the set of values in a dictionary and returns them as an array of typed objects.
+		/// </summary>
+		/// <param name="dictionary">
+		/// A <see cref="Dictionary`2"/> to extract an array of values from
+		/// </param>
+		/// <returns>
+		/// An array of <see cref="VALUE_TYPE"/> objects taken from the Values property of the dictionary, or NULL if the dictionary is NULL
+		/// </returns>
 		public static  VALUE_TYPE[] Convert<KEY_TYPE, VALUE_TYPE>(Dictionary<KEY_TYPE, VALUE_TYPE> dictionary)
 		{
-			VALUE_TYPE[] col = (VALUE_TYPE[]) new object[dictionary.Count];
+			if (dictionary == null)
+			{
+				return null;
+			}
+			
+			VALUE_TYPE[] col = new VALUE_TYPE[dictionary.Count];
 			dictionary.Values.CopyTo(col, 0);
-			return (VALUE_TYPE[])col;
+			return col;
 		}
 	}
 }
--- a/Logging/LogNotifier.cs	Sun Jan 04 14:44:19 2009 +0000
+++ b/Logging/LogNotifier.cs	Sun Jan 04 18:45:32 2009 +0000
@@ -62,7 +62,6 @@
 		
 		public static void Info(Type logFromType, Object message, Exception e)
 		{
-			Console.WriteLine("Info:  "+(InfoLogEventOccurred!=null ? "true":"false")+" "+message);
 			if (InfoLogEventOccurred!=null)
 			{
 				InfoLogEventOccurred(logFromType, message, e);