From 490db100a68150b47b5e3494a1cbba2d28b1b572 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 10 Feb 2009 19:18:52 +0000 Subject: [PATCH] Found a bug in LazyLoad code for Format values if the value is an Enum and there is no value for it in the Format file. Specifically the error was related to the value of TransUI in the D.C. Cook format file for the TransTypes records. --- PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs index 99bf96be..abc882c4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs @@ -295,7 +295,12 @@ namespace VEPROMS.CSLA.Library if (ll == null) { XmlNode xn = SelectSingleNode(xPath); - ll = new LazyLoad>(xn != null ? (Nullable)Enum.Parse(typeof(T), xn.InnerText) : null); + if (xn == null) + ll = new LazyLoad(null); + else if (xn.Value == "")// No value specified - Use zero value if it is defined - GetName returns a null if it is not defined + ll = new LazyLoad>(Enum.GetName(typeof(T), 0) != null ? (Nullable) Enum.Parse(typeof(T), "0") : null); + else + ll = new LazyLoad>((Nullable)Enum.Parse(typeof(T), xn.InnerText)); } return ll.Value; }