AssemblyCSharp.LO_XMLTool.Serializer C# (CSharp) Method

Serializer() public static method

序列化
public static Serializer ( Type type, object obj ) : string
type System.Type 类型
obj object 对象
return string
		public static string Serializer(Type type, object obj)
		{
			MemoryStream Stream = new MemoryStream();
			XmlSerializer xml = new XmlSerializer(type);
			try
			{
				//序列化对象
				xml.Serialize(Stream, obj);
			}
			catch (InvalidOperationException)
			{
				throw;
			}
			Stream.Position = 0;
			StreamReader sr = new StreamReader(Stream);
			string str = sr.ReadToEnd();
			
			sr.Dispose();
			Stream.Dispose();
			
			return str;
		}