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.

This commit is contained in:
Rich 2009-02-10 19:18:52 +00:00
parent 6e9c4be777
commit 490db100a6

View File

@ -295,7 +295,12 @@ namespace VEPROMS.CSLA.Library
if (ll == null) if (ll == null)
{ {
XmlNode xn = SelectSingleNode(xPath); XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<Nullable<T>>(xn != null ? (Nullable<T>)Enum.Parse(typeof(T), xn.InnerText) : null); if (xn == null)
ll = new LazyLoad<T?>(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<Nullable<T>>(Enum.GetName(typeof(T), 0) != null ? (Nullable<T>) Enum.Parse(typeof(T), "0") : null);
else
ll = new LazyLoad<Nullable<T>>((Nullable<T>)Enum.Parse(typeof(T), xn.InnerText));
} }
return ll.Value; return ll.Value;
} }