You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace DQ.Construction.NewLook.DataTemplate
|
|
{
|
|
/// <summary>
|
|
/// DateTemplateMatchManager
|
|
/// </summary>
|
|
public static class DateTemplateMatchManager
|
|
{
|
|
/// <summary>
|
|
/// 加载模板
|
|
/// </summary>
|
|
/// <param name="path">path</param>
|
|
/// <returns>config</returns>
|
|
internal static DateTemplateMatch LoadForm(string path)
|
|
{
|
|
try
|
|
{
|
|
using (var stream = File.OpenRead(path))
|
|
{
|
|
XmlSerializer xmlSearializer = new XmlSerializer(typeof(DateTemplateMatch));
|
|
return (DateTemplateMatch)xmlSearializer.Deserialize(stream);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存模板
|
|
/// </summary>
|
|
/// <param name="path">path</param>
|
|
/// <param name="config">config</param>
|
|
internal static void SaveTo(string path, DateTemplateMatch config)
|
|
{
|
|
string strSolutionPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
if (!Directory.Exists(strSolutionPath))
|
|
{
|
|
Directory.CreateDirectory(strSolutionPath);
|
|
}
|
|
|
|
try
|
|
{
|
|
using (var sw = new StreamWriter(path))
|
|
{
|
|
// 创建XML命名空间
|
|
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
|
ns.Add(string.Empty, string.Empty);
|
|
XmlSerializer serializer = new XmlSerializer(typeof(DateTemplateMatch));
|
|
serializer.Serialize(sw, config, ns);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|