public string CreateKeyStringValue(object propertyValue) { if (propertyValue is DateTime) { if (this.UseBinaryFormatForDates) { string prefix; if (this.UseSmallCasing.HasValue && this.UseSmallCasing.Value) { prefix = "DaTeTiMe'"; } else { prefix = "datetime'"; } string dateTime = prefix + XmlConvert.ToString((DateTime)propertyValue, XmlDateTimeSerializationMode.RoundtripKind) + "'"; byte[] bytes = (new UTF8Encoding()).GetBytes(dateTime); return(TypeData.FormatByteArrayForKey(bytes, this.UseSmallCasing)); } else { string formatted = TypeData.FormatForKey(propertyValue, this.UseSmallCasing, Versioning.Server.SupportsV2Features); formatted = Uri.EscapeDataString(formatted); return(formatted); } } else { string formatted = TypeData.FormatForKey(propertyValue, this.UseSmallCasing, Versioning.Server.SupportsV2Features); if (this.EscapeUriValues) { // for some silly reason, TypeData.FormatForKey does this for already for doubles UNLESS IT PUTS THE 'D' if (!(propertyValue is double) || Versioning.Server.SupportsV2Features) { formatted = Uri.EscapeDataString(formatted); } } if (!(propertyValue is String) && this.CleanUpSpecialCharacters) { return(formatted.Replace("+", "").Replace("%2B", "")); } else { return(formatted); } } }