Statistics
| Branch: | Revision:

root / trunk / hammock / src / net35 / Hammock.Extras / Serialization / XmlSerializer.cs @ 0eea575a

History | View | Annotate | Download (1.1 kB)

1
using System;
2

    
3
namespace Hammock.Extras.Serialization
4
{
5
    public class XmlSerializer : SerializerBase
6
    {
7
        public override T Deserialize<T>(RestResponse<T> response)
8
        {
9
            var root = typeof (T).Name.ToLowerInvariant();
10

    
11
            return (T)DeserializeXmlWithRoot(response.Content, typeof(T), root);
12
        }
13

    
14
#if NET40
15
        public override dynamic DeserializeDynamic<T>(RestResponse<T> response)
16
        {
17
            var root = typeof(T).Name.ToLowerInvariant();
18

    
19
            return DeserializeXmlWithRoot(response.Content, typeof(T), root);
20
        }
21
#endif
22

    
23
        public override object Deserialize(RestResponse response, Type type)
24
        {
25
            var root = type.Name.ToLowerInvariant();
26

    
27
            return DeserializeXmlWithRoot(response.Content, type, root);
28
        }
29

    
30
        public override string Serialize(object instance, Type type)
31
        {
32
            var root = type.Name.ToLowerInvariant();
33
            
34
            return SerializeXmlWithRoot(instance, type, root);
35
        }
36

    
37
        public override string ContentType
38
        {
39
            get { return "text/xml"; }
40
        }
41
    }
42
}