123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Xml;
- namespace WeiXin.Library.Handlers
- {
-
-
-
- public class HandlerFactory
- {
-
-
-
-
-
- public static IHandler CreateHandler(string requestXml)
- {
- IHandler handler = null;
- if (!string.IsNullOrEmpty(requestXml))
- {
-
- XmlDocument doc = new System.Xml.XmlDocument();
- doc.LoadXml(requestXml);
- XmlNode node = doc.SelectSingleNode("/xml/MsgType");
- if (node != null)
- {
- XmlCDataSection section = node.FirstChild as XmlCDataSection;
- if (section != null)
- {
- string msgType = section.Value;
- switch (msgType)
- {
- case "text":
- handler = new TextHandler(requestXml);
- break;
- case "event":
- handler = new EventHandler(requestXml);
- break;
- }
- }
- }
- }
- return handler;
- }
- }
- }
|