/// <summary> /// Returns true if the given value can be converted into a string /// </summary> public override bool CanConvertToString(object value, IValueSerializerContext context) { // When invoked by the serialization engine we can convert to string only for some instances if (!(value is CacheMode)) { return(false); } CacheMode instance = (CacheMode)value; #pragma warning suppress 6506 // instance is obviously not null return(instance.CanSerializeToString()); }
/// <summary> /// Converts the value into a string. /// </summary> public override string ConvertToString(object value, IValueSerializerContext context) { if (value is CacheMode) { CacheMode instance = (CacheMode)value; // When invoked by the serialization engine we can convert to string only for some instances #pragma warning suppress 6506 // instance is obviously not null if (!instance.CanSerializeToString()) { // Let base throw an exception. return(base.ConvertToString(value, context)); } #pragma warning suppress 6506 // instance is obviously not null return(instance.ConvertToString(null, System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS)); } return(base.ConvertToString(value, context)); }