I'm trying to create a new instance of a property by deserializing a json string. The call to JsonConvert.DeserializeObject<T>(string) works when I explicitly state the type of T:
var foo = JsonConvert.DeserializeObject<Resource>(propertyValue.ToString());
But I'd like to pass it PropertyInfo.PropertyType:
var foo = JsonConvert.DeserializeObject<prop.PropertyType>(propertyValue.ToString());
I get "type or namespace 'prop' could not be found." This doesn't make sense to me, I thought that PropertyType is a Type.
PropertyTypeis a property that holds aType; it is not a type itself. Generics must be able to be resolved at compile time.