public static string ToString(XmlMqConfigArray config) { try { var tx = new StringWriter(); var xmlSerializer = new XmlSerializer(typeof(XmlMqConfigArray)); xmlSerializer.Serialize(tx, config); return(tx.ToString()); } catch { return(string.Empty); } }
/// <summary> /// 解析配置文件 /// </summary> /// <param name="line">序列化字符</param> /// <param name="config">配置信息</param> /// <returns>序列化结果</returns> public static bool TryParse(string line, out XmlMqConfigArray config) { config = null; try { var tx = new StringReader(line); var xmlSerializer = new XmlSerializer(typeof(XmlMqConfigArray)); config = (XmlMqConfigArray)xmlSerializer.Deserialize(tx); return(true); } catch { return(false); } }