internal static string GetValue(Property?property, FilterOperator op, object value, FilterMode filterMode = FilterMode.Normal) { string val; val = value.ToString(); if (value.GetType().IsEnum) { var attrib = ((Enum)value).GetEnumAttribute <XmlEnumAttribute>(); if (attrib != null) { val = attrib.Name; } } else { if (value is DateTime) { val = DeserializationHelpers.ConvertToPrtgDateTime((DateTime)value).ToString(CultureInfo.InvariantCulture); } else if (value is TimeSpan) { val = DeserializationHelpers.ConvertToPrtgTimeSpan((TimeSpan)value).ToString(CultureInfo.InvariantCulture); } else if (value is bool) { val = GetBool(property, value); } else if (value is IStringEnum) { val = ((IStringEnum)value).StringValue; } } if (filterMode != FilterMode.Raw) { var converter = property?.GetEnumAttribute <ValueConverterAttribute>(); if (converter != null) { //If we leave all the padding we won't be able to detect numbers that have trailing 0's. e.g. //0000000060 for 60 seconds won't provide room to detect 600 seconds (which would be 0000000600) if (converter.Converter is IZeroPaddingConverter && op == FilterOperator.Contains) { val = ((IZeroPaddingConverter)converter.Converter).SerializeWithPadding(val, false); } else { val = converter.Converter.Serialize(val)?.ToString(); } } } return(val); }