I have a lot of entities which previously used to have properties of type for example string. I need to change these to a custom type - MultilingualValue<T>, where T in this case would be string. I can easily convert from string to the custom Type. Is it possible to configure JSON.Net such that everywhere it encounters a conversion from any type, to a MultilingualValue<T>, some custom code is called rather than it's native conversion?
Sample code
public class ProductBefore
{
public int Id { get; set; }
public string Name { get; set; }
}
public class ProductAfter
{
public int Id { get; set; }
public MultilingualValue<string> Name { get; set; }
}
I would like to be able to deserialize anything which was stored as ProductBefore, into ProductAfter automatically. The MultilingualValue<string> can be initialised with a string parameter in the constructor, so it's relatively easy to create it from the original string.