示例#1
0
 /// <summary>
 /// 从流中读取文本,解析出类型 <paramref name="type"/> 的对象。
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="reader"></param>
 /// <returns></returns>
 public T Deserialize <T>(XmlTextReader reader)
 {
     using (var deser = new XmlDeserialize(this, reader, Option))
     {
         return(deser.Deserialize <T>());
     }
 }
示例#2
0
        public object Deserialize(string xml, Type type)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }

            using (var sr = new StringReader(xml))
                using (var reader = XmlReader.Create(sr))
                    using (var deser = new XmlDeserialize(this, reader, Option))
                    {
                        return(deser.Deserialize(type));
                    }
        }
示例#3
0
        public T Deserialize <T>(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(default(T));
            }

            using (var sr = new StringReader(xml))
                using (var reader = XmlReader.Create(sr))
                    using (var deser = new XmlDeserialize(this, reader, Option))
                    {
                        return(deser.Deserialize <T>());
                    }
        }