private static string PropertyValueToString(object propertyValue) { Type type = propertyValue.GetType(); if (IsEnum(type)) { EnumStringAttribute enumStringAttr = GetEnumStringAttribute(propertyValue as Enum); if (enumStringAttr != null) { return(enumStringAttr.String); } } else if (propertyValue is bool) { if ((bool)propertyValue) { return("true"); } return("false"); } return(propertyValue.ToString()); }
private static string PropertyValueToString(object propertyValue) { Type type = propertyValue.GetType(); if (IsEnum(type)) { EnumStringAttribute enumStringAttr = GetEnumStringAttribute(propertyValue as Enum); if (enumStringAttr != null) { return(enumStringAttr.String); } } else if (propertyValue is bool) { if ((bool)propertyValue) { return("true"); } return("false"); } else if (propertyValue is DateTimeOffset?) { DateTimeOffset?dateTime = propertyValue as DateTimeOffset?; if (dateTime.HasValue) { // ISO 8601 format return(System.Xml.XmlConvert.ToString(dateTime.Value)); } else { return(null); } } return(propertyValue.ToString()); }