Exemplo n.º 1
0
        public virtual T Deserialize <T>(IRestResponse response)
        {
            if (string.IsNullOrEmpty(response.Content))
            {
                return(default(T));
            }
            XDocument xdoc = XDocument.Parse(response.Content);
            XElement  root = xdoc.Root;

            if (StringExtensions.HasValue(this.RootElement) && xdoc.Root != null)
            {
                root = xdoc.Root.Element(XmlExtensions.AsNamespaced(this.RootElement, this.Namespace));
            }
            if (!StringExtensions.HasValue(this.Namespace))
            {
                XmlDebuggingDeserializer.RemoveNamespace(xdoc);
            }
            T    instance = Activator.CreateInstance <T>();
            Type type     = instance.GetType();

            return(!ReflectionExtensions.IsSubclassOfRawGeneric(type, typeof(List <>)) ? (T)this.Map((object)instance, root) : (T)this.HandleListDerivative(root, type.Name, type));
        }