Exemplo n.º 1
0
        /// <summary>
        /// 将消息写入流。
        /// </summary>
        /// <param name="stream">流。</param>
        public void WriteResponseText(Stream stream)
        {
            StreamWriter writer = new StreamWriter(stream);
            XDocument    doc    = new XDocument();
            var          root   = new XElement("xml");

            root.Add(new XElement("ToUserName", ToUser));
            root.Add(new XElement("FromUserName", FromUser));
            root.Add(new XElement("CreateTime", (int)(CreateDate.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalSeconds));
            root.Add(new XElement("MsgType", Type));

            var nodes = GetResponseNode();

            if (nodes != null)
            {
                root.Add(nodes);
            }
            doc.Add(root);
            doc.Save(writer);
        }