With generic-types, it's possible to give a dynamic type, but is it possible to also give a dynamic value ?
For example, I receive an XML response from a Rest API and I want to Deserialize it into an object:
<tsResponse>
<value id="hello"/>
</tsResponse>
[XmlRoot("tsResponse")]
public class TsResponse<T, string myNodeName>
{
[XmlElement(myNodeName)]
public T Object { get; set; }
}
public class User
{
[XmlAttribute("id")]
public string Id { get; set; }
}
To make it works I need to call something like this:
using (StringReader sr = new StringReader(xml))
{
XmlSerializer serializer = new XmlSerializer(typeof(TsResponse<User>));
TsResponse<User, "value"> responseXml = (TsResponse<User, "value">)serializer.Deserialize(sr);
}
Is it possible to do something like this ?