usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Text;namespaceweixin.core{ Public Static classJobbase {Private Staticidictionary<string,string>parnamedictionary; Private Staticidictionary<string,string>functiondictionary; Private Staticidictionary<string,string>iplatformdictionary; /// <summary> ///get the Paraminfo value from the configuration file/// </summary> /// <param name= "Parname" ></param> /// <returns></returns> Public Static stringGetconfparamvalue (Paramenum parname) {if(parnamedictionary==NULL) {parnamedictionary=springcontainer.getobject<paramlist> ("systemlist"). Paraminfolist; } returnparnamedictionary[parname.tostring ()]; } Public Static stringGetconffunctionvalue (functionenum functionname) {if(functiondictionary==NULL) {functiondictionary=springcontainer.getobject<paramlist> ("systemlist"). Sendxmlpathlist; } returnfunctiondictionary[functionname.tostring ()]; } Public Static stringGetconfapivalue (Iplatformenum platformname) {if(iplatformdictionary==NULL) {iplatformdictionary= Springcontainer.getobject<paramlist> ("systemlist"). Iplatformlist; } returniplatformdictionary[platformname.tostring ()]; } Public Static stringBytes (stringstr) { stringNewstr =string. Empty; inti = encoding.getencoding ("GB2312"). GetByteCount (str); if(i> -) { foreach(CharChartempinchstr) {Newstr+=chartemp.tostring (); if(Encoding.GetEncoding ("GB2312"). GetByteCount (newstr) = = -) {Newstr+="..."; Break; } } returnNewstr; } returnstr; } }}
<?XML version= "1.0" encoding= "Utf-8"?><Objectsxmlns= "Http://www.springframework.net"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd"> <ObjectID= "Systemlist"type= "Yto." Weixin.core.paramlist,yto. Weixin.core "> < Propertyname= "Paraminfolist"> <DictionaryKey-type= "string"Value-type= "string"> <entryKey= "AppID"value= "Wxf96dbe9e4723b1b8"/> <entryKey= "Appsecret"value= "1d010913658421023c6ebc403580e8ea"/> </Dictionary> </ Property> < Propertyname= "Iplatformlist"> <DictionaryKey-type= "string"Value-type= "string"> <entryKey= "Tokenxml"value= "C:\Data\qiyun\XML\Token.xml"/> </Dictionary> </ Property> </Object></Objects>
Spring object instantiation, gets the value in the configuration file (property is IDictionary type of data)