From d874c571825d79da0523ee4f3c29f56325d58e5c Mon Sep 17 00:00:00 2001 From: "agrath@gmail.com" Date: Sat, 5 May 2012 15:46:21 -1200 Subject: [PATCH] Add support for Guid and Nullable for macro properties in properties + if (prop.PropertyType.IsGenericType && prop.PropertyType.Name == "Nullable`1") + { + Type underlyingType = Nullable.GetUnderlyingType(prop.PropertyType); + if (underlyingType != null) + { + object safeValue = null; + if (propValue != null) + { + if (!(underlyingType == typeof(Guid))) + { + prop.SetValue(control, Convert.ChangeType(propValue, underlyingType), null); + } + else + { + Guid g = Guid.Empty; + if (Guid.TryParse(string.Format("{0}", propValue), out g)) + { + prop.SetValue(control, g, null); + } + } + } + else + { + prop.SetValue(control, safeValue, null); + } + } + } + else + { + //GE 06-05-2012: Handle Guid properties as Convert.ChangeType throws on string->Guid + if (!(prop.PropertyType == typeof(Guid))) + { + prop.SetValue(control, Convert.ChangeType(propValue, prop.PropertyType), null); + } + else + { + Guid g = Guid.Empty; + if (Guid.TryParse(string.Format("{0}", propValue), out g)) + { + prop.SetValue(control, g, null); + } + } + } + } } }