using System.IO;using System.Xml;publicabstractclassXMLReaderBase<T>where T :new(){protectedstring m_Path;protectedstring m_RootNodeName;protectedXmlNodeList m_NodeList;protectedT m_Result;publicXMLReaderBase(string path,string rootNodeName){
m_Path = path;
m_RootNodeName = rootNodeName;
m_Result =newT();}publicTReadXml(){if(File.Exists(m_Path)){XmlDocument xmlDoc =newXmlDocument();
xmlDoc.Load(m_Path);
m_NodeList = xmlDoc.SelectSingleNode(m_RootNodeName).ChildNodes;if(m_NodeList !=null){
m_Result=Analysis();}}return m_Result;}protectedabstractTAnalysis();//<PJConfig>// <IsServer>True</IsServer>//</PJConfig>privatevoidAnalysisTest1(){foreach(XmlElement node in m_NodeList)//1层{switch(node.Name){case"NodeName":break;}}}//<PJConfig>// <Info>// <IsServer>True</IsServer>// <Info>//</PJConfig>privatevoidAnalysisTest2(){foreach(XmlElement node in m_NodeList){foreach(XmlElement x in node.ChildNodes){switch(x.Name){case"NodeName":break;}}}}}
using System.Xml;publicclassGameConfig{}publicclassXMLReader_GameConfig:XMLReaderBase<GameConfig>{publicXMLReader_GameConfig(string path,string rootNodeName):base(path, rootNodeName){}protectedoverrideGameConfigAnalysis(){foreach(XmlElement node in m_NodeList){foreach(XmlElement x in node.ChildNodes){switch(x.Name){default:break;}}}return m_Result;}}