Ejemplo n.º 1
0
        public static T ToObject <T>(this XmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("XmlNode");
            }

            //XmlSerializer serializer = new XmlSerializer(typeof(T));
            XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(T) }).GetNValue(0);

            return((T)serializer.Deserialize(new XmlNodeReader(node)));
        }
Ejemplo n.º 2
0
        public static object ToObject(this XmlNode node, Type type, XmlAttributeOverrides overrides)
        {
            if (node == null)
            {
                throw new ArgumentNullException("XmlNode");
            }

            if (type == null)
            {
                throw new ArgumentException("Type");
            }

            XmlSerializer serializer = overrides != null ? new XmlSerializer(type, overrides) : XmlSerializer.FromTypes(new[] { type }).GetNValue(0);

            return(serializer.Deserialize(new XmlNodeReader(node)));
        }