修改导入显示
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user