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.
18 lines
512 B
18 lines
512 B
using System.Runtime.Serialization;
|
|
using System.Text;
|
|
using System.Xml;
|
|
|
|
namespace Shentun.Utilities.Data
|
|
{
|
|
public class DataContractSerializerHelper
|
|
{
|
|
public static void Write<T>(T instance, string fileName)
|
|
{
|
|
DataContractSerializer serializer = new DataContractSerializer(typeof(T));
|
|
using (XmlWriter writer = new XmlTextWriter(fileName, Encoding.UTF8))
|
|
{
|
|
serializer.WriteObject(writer, instance);
|
|
}
|
|
}
|
|
}
|
|
}
|