From 375b488be2666cd56e70728624f4eadaefee0440 Mon Sep 17 00:00:00 2001
From: chenghaoran <chenghaoran@ipilotwhale.com>
Date: 星期二, 12 三月 2024 17:36:49 +0800
Subject: [PATCH] 优化项目结构;
---
WPFProject/Utils/XmlUtil.cs | 82 ++++++++++++++++++++--------------------
1 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/Utils/XmlUtil.cs b/WPFProject/Utils/XmlUtil.cs
similarity index 99%
rename from Utils/XmlUtil.cs
rename to WPFProject/Utils/XmlUtil.cs
index 5353449..5780a16 100644
--- a/Utils/XmlUtil.cs
+++ b/WPFProject/Utils/XmlUtil.cs
@@ -1,41 +1,41 @@
-锘縰sing System;
-using System.IO;
-using System.Xml.Serialization;
-
-namespace WPFProject.Utils
-{
- public class XmlUtil
- {
- /// <summary>
- /// 灏嗗璞″簭鍒楀寲鍒癤ml鏂囦欢涓�
- /// </summary>
- /// <param name="data">瀵硅薄</param>
- /// <param name="filePath">xml璺緞</param>
- public static void SerialToFile(object data, string filePath)
- {
- XmlSerializer serializer = new XmlSerializer(data.GetType());
- string content = string.Empty;
- //serialize
- using (StringWriter writer = new StringWriter())
- {
- serializer.Serialize(writer, data);
- content = writer.ToString();
- }
- //save to file
- using (StreamWriter stream_writer = new StreamWriter(filePath))
- {
- stream_writer.Write(content);
- }
- }
-
- public static T DeserialFromXml<T>(string filePath)
- {
- XmlSerializer serializer = new XmlSerializer(typeof(T));
- using (StreamReader reader = new StreamReader(filePath))
- {
- return (T) serializer.Deserialize(reader);
- }
- }
-
- }
-}
+锘縰sing System;
+using System.IO;
+using System.Xml.Serialization;
+
+namespace WPFProject.Utils
+{
+ public class XmlUtil
+ {
+ /// <summary>
+ /// 灏嗗璞″簭鍒楀寲鍒癤ml鏂囦欢涓�
+ /// </summary>
+ /// <param name="data">瀵硅薄</param>
+ /// <param name="filePath">xml璺緞</param>
+ public static void SerialToFile(object data, string filePath)
+ {
+ XmlSerializer serializer = new XmlSerializer(data.GetType());
+ string content = string.Empty;
+ //serialize
+ using (StringWriter writer = new StringWriter())
+ {
+ serializer.Serialize(writer, data);
+ content = writer.ToString();
+ }
+ //save to file
+ using (StreamWriter stream_writer = new StreamWriter(filePath))
+ {
+ stream_writer.Write(content);
+ }
+ }
+
+ public static T DeserialFromXml<T>(string filePath)
+ {
+ XmlSerializer serializer = new XmlSerializer(typeof(T));
+ using (StreamReader reader = new StreamReader(filePath))
+ {
+ return (T) serializer.Deserialize(reader);
+ }
+ }
+
+ }
+}
--
Gitblit v1.9.1