using System.Collections.Generic;
using RestSharp.Deserializers;
using RestSharp.Extensions;
using System.Diagnostics;
using RestSharp.Serializers;
using System.Xml.Serialization;
public bool Found { get; set; }
public string Description { get; set; }
public string BuildDate { get; set; }
public string ModelYear { get; set; }
public List<Option> OptionList { get; set; }
public string Code { get; set; }
public string Value { get; set; }
public static void Test()
RestSharp.RestResponse response = new RestSharp.RestResponse();
response.ContentType = "text/xml";
var xmlDeserializer = new RestSharp.Deserializers.XmlDeserializer();
var results = xmlDeserializer.Deserialize<Vehicle>(response);
Console.WriteLine("\nTesting {0}, deserialization result:", xmlDeserializer.GetType());
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(results, Newtonsoft.Json.Formatting.Indented));
Assert.IsTrue(XElement.Parse(xml).Elements("optionList").Elements("option").Select(e => e.Value).SequenceEqual(results.OptionList.Select(o => o.Value)));
Console.WriteLine("Descriptions deserialized successfully.");
var xml = @"<vehicle found=""1"">
<description>VehicleDescText</description>
<buildDate>2000-11-20</buildDate>
<modelYear>2001</modelYear>
<option code=""UH8"">OptionDesc1</option>
<option code=""UH8"">OptionDesc2</option>
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
public static void IsTrue(bool value, string message)
throw new AssertionFailedException(message ?? "failed");
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("Exception thrown: ");