You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							29 lines
						
					
					
						
							816 B
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							29 lines
						
					
					
						
							816 B
						
					
					
				
								using System;
							 | 
						|
								using System.Collections.Generic;
							 | 
						|
								using System.Linq;
							 | 
						|
								using System.Text;
							 | 
						|
								using System.Threading.Tasks;
							 | 
						|
								using System.Xml.Serialization;
							 | 
						|
								
							 | 
						|
								namespace Shentun.Peis.PlugIns.Extensions
							 | 
						|
								{
							 | 
						|
								    public class XmlHelper
							 | 
						|
								    {
							 | 
						|
								        public static string SerializeToXml<T>(T obj)
							 | 
						|
								        {
							 | 
						|
								            XmlSerializer serializer = new XmlSerializer(typeof(T));
							 | 
						|
								            using (StringWriter textWriter = new StringWriter())
							 | 
						|
								            {
							 | 
						|
								                serializer.Serialize(textWriter, obj);
							 | 
						|
								                return textWriter.ToString();
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        public static T DeserializeXml<T>(string xml)
							 | 
						|
								        {
							 | 
						|
								            var serializer = new XmlSerializer(typeof(T));
							 | 
						|
								            using var reader = new StringReader(xml);
							 | 
						|
								            return (T)serializer.Deserialize(reader);
							 | 
						|
								        }
							 | 
						|
								    }
							 | 
						|
								}
							 |