From: Eric C. <ecr...@us...> - 2006-09-25 19:03:16
|
User: ecrutchfield Date: 06/09/25 12:02:48 Modified: andromda-aspdotnet/src/main/resources/resources FormPopulator.cs Log: added better error handling Revision Changes Path 1.2 +13 -0 cartridges/andromda-aspdotnet/src/main/resources/resources/FormPopulator.cs Index: FormPopulator.cs =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-aspdotnet/src/main/resources/resources/FormPopulator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- FormPopulator.cs 17 Sep 2006 17:30:52 -0000 1.1 +++ FormPopulator.cs 25 Sep 2006 19:02:48 -0000 1.2 @@ -22,6 +22,15 @@ /// <param name="propertyName">The property of the form where the value will be written.</param> public static void PopulateForm(System.Web.UI.Control fromControl, object toForm, string propertyName) { + if (fromControl == null) + throw new ArgumentNullException("fromControl"); + + if (toForm == null) + throw new ArgumentNullException("toForm"); + + if (propertyName == null) + throw new ArgumentNullException("propertyName"); + object val = null; switch(fromControl.GetType().FullName) { @@ -47,6 +56,10 @@ default: throw new ArgumentException(String.Format("The {0} control is not yet supported.", fromControl.GetType().FullName)); } + + if (val == null) + throw new ArgumentNullException(String.Format("The value of the {0} control can't be null.", fromControl.GetType().FullName)); + PropertyInfo propInfo = toForm.GetType().GetProperty(propertyName); object assignedValue = null; switch (propInfo.PropertyType.Name) |