Skip to content

Instantly share code, notes, and snippets.

@clausjoergensen
Created July 20, 2011 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clausjoergensen/1096008 to your computer and use it in GitHub Desktop.
Save clausjoergensen/1096008 to your computer and use it in GitHub Desktop.
namespace RestSharp.Deserializers
{
public class XmlDeserializer : IDeserializer
{
...
private void Map(object x, XElement root)
{
...
else if (type.IsGenericType)
{
var t = type.GetGenericArguments()[0];
var list = (IList)Activator.CreateInstance(type);
// is 'root' meant to be the content of the ENTIRE xml document?
var container = GetElementByName(root, prop.Name.AsNamespaced(Namespace));
var first = container.Elements().FirstOrDefault();
var elements = container.Elements(first.Name);
PopulateListFromElements(t, elements, list);
prop.SetValue(x, list, null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment