예제 #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var converter = new ArrayOfTypeReferencesConverter();
            var result = (TypeReference[])converter.ReadJson(reader, objectType, existingValue, serializer);
            if (result == null)
            {
                return null;
            }

            if (result.Length == 1)
            {
                return result[0];
            }

            throw new ArgumentException("Expected one type and found multiple");
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var converter = new ArrayOfTypeReferencesConverter();
            var result    = (TypeReference[])converter.ReadJson(reader, objectType, existingValue, serializer);

            if (result == null)
            {
                return(null);
            }

            if (result.Length == 1)
            {
                return(result[0]);
            }

            throw new ArgumentException("Expected one type and found multiple");
        }