CreateCommon/XmlUtility.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/******************************************************************************
*
* Filename: XmlUtility.cs
* Description: xml实用类,主要包含序列化/返序列化对象, 序列化保存XML文件以及从XML文件反序列化
* Author : liangjw
* Created Mark: 2011-06-09
* E-mail: liangjw0504@163.com
* Version: V1.0.0.0
* Company: : Copyright (C) 2013 Create Family Wealth Power By Peter All Rights Reserved
* Remark: 无
* Update Author: 无
* Update Description: 无
* Update Mark : 无
*
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using System.Xml;
namespace CreateCommon
{
/// <summary>
/// Xml实用类
/// </summary>
public class XmlUtility
{
#region 序列化/返序列化对象
/// <summary>
/// 序列化对象
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="t">对象</param>
/// <returns></returns>
public static string Serialize<T>(T t)
{
using (StringWriter sw = new StringWriter())
{
XmlSerializer xz = new XmlSerializer(t.GetType());
xz.Serialize(sw, t);
return sw.ToString();
}
}
/// <summary>
/// 反序列化为对象
/// </summary>
/// <param name="type">对象类型</param>
/// <param name="s">对象序列化后的Xml字符串</param>
/// <returns></returns>
public static object Deserialize(Type type, string s)
{
using (StringReader sr = new StringReader(s))
{
XmlSerializer xz = new XmlSerializer(type);
return xz.Deserialize(sr);
后面还有 70 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。