changeset 4:01fc09ab63e2

Re #7 - Add tests for INI parsing * Add DuplicateIniSectionException to make exception cause more obvious
author IBBoard <dev@ibboard.co.uk>
date Sun, 18 Jan 2009 14:29:52 +0000
parents 3c26f463977a
children 7e06c0699257
files DuplicateIniLineException.cs DuplicateIniSectionException.cs IBBoard.Ini.mdp IniFile.cs
diffstat 4 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/DuplicateIniLineException.cs	Sun Jan 18 14:18:07 2009 +0000
+++ b/DuplicateIniLineException.cs	Sun Jan 18 14:29:52 2009 +0000
@@ -1,4 +1,4 @@
-// This file (DuplicateIniLineException.cs) is a part of [PROJECT NAME] and is copyright 2009 IBBoard.
+// This file (DuplicateIniLineException.cs) is a part of the IBBoard.Ini library and is copyright 2009 IBBoard.
 //
 // The file and the library/program it is in are licensed under the GNU LGPL license. Please see COPYING.LGPL for more information and the full license.
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DuplicateIniSectionException.cs	Sun Jan 18 14:29:52 2009 +0000
@@ -0,0 +1,18 @@
+// This file (DuplicateIniSectionException.cs) is a part of the IBBoard.Ini library and is copyright 2009 IBBoard.
+//
+// The file and the library/program it is in are licensed under the GNU LGPL license. Please see COPYING.LGPL for more information and the full license.
+
+using System;
+
+namespace IBBoard.Ini
+{
+	/// <summary>
+	/// An exception that indicates that a second IniSection has been added to an IniFile with the same name as a section already in the IniFile
+	/// </summary>
+	public class DuplicateIniSectionException : ArgumentException
+	{
+		public DuplicateIniSectionException(string sectionName) : base("The INI file already contained a section called ["+sectionName+"]")
+		{
+		}
+	}
+}
--- a/IBBoard.Ini.mdp	Sun Jan 18 14:18:07 2009 +0000
+++ b/IBBoard.Ini.mdp	Sun Jan 18 14:29:52 2009 +0000
@@ -29,6 +29,7 @@
     <File name="IniBlankLine.cs" subtype="Code" buildaction="Compile" />
     <File name="IniCommentLine.cs" subtype="Code" buildaction="Compile" />
     <File name="DuplicateIniLineException.cs" subtype="Code" buildaction="Compile" />
+    <File name="DuplicateIniSectionException.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
--- a/IniFile.cs	Sun Jan 18 14:18:07 2009 +0000
+++ b/IniFile.cs	Sun Jan 18 14:29:52 2009 +0000
@@ -40,7 +40,7 @@
 			}
 			else
 			{
-				throw new ArgumentException("Ini section already exists with name " + section.Name);
+				throw new DuplicateIniSectionException(section.Name);
 			}
 		}