private static Guid GetGuidPropertyValue(object value)
{
// Use reflection to find the Guid or the GUID
// property on the object.
var pi = value.GetType().GetProperty("Guid");
if (pi == null)
{
pi = value.GetType().GetProperty("GUID");
}
var id = pi == null ? Guid.NewGuid() : (Guid)pi.GetValue(value);
return id;
}