Beispiel #1
0
        public override WellKnownProblem ReadJson(JsonReader reader, Type objectType, WellKnownProblem existingValue, bool hasExistingValue, JsonSerializer serializer)
        {
            string s = (string)reader.Value;

            if (WellKnownProblems.TryLookup(s, out var problem))
            {
                return(problem);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string s)
            {
                if (WellKnownProblems.TryLookup(s, out var problem))
                {
                    return(problem);
                }
                else
                {
                    return(null);
                }
            }

            return(base.ConvertFrom(context, culture, value));
        }