修改导入显示

This commit is contained in:
admin
2020-12-19 13:04:35 +08:00
parent a82c4d5096
commit ee176b4e24
10 changed files with 383 additions and 173 deletions

View File

@@ -53,7 +53,31 @@ namespace U8AppMain
}
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="s"></param>
/// <param name="encoding"></param>
/// <returns></returns>
public static T XmlDeserialize<T>(string s, Encoding encoding)
{
if (string.IsNullOrEmpty(s))
throw new ArgumentNullException("s");
if (encoding == null)
throw new ArgumentNullException("encoding");
XmlSerializer mySerializer = new XmlSerializer(typeof(T));
s = s.Replace(" ", " ");
using (MemoryStream ms = new MemoryStream(encoding.GetBytes(s)))
{
using (StreamReader sr = new StreamReader(ms, encoding))
{
return (T)mySerializer.Deserialize(sr);
}
}
}
}
}