24 lines
		
	
	
		
			769 B
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			24 lines
		
	
	
		
			769 B
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Threading.Tasks;
							 | 
						|||
| 
								 | 
							
								using System.Xml;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace DM_Weight.util
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public class CommonClass
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
							 | 
						|||
| 
								 | 
							
								        public string ReadAppSetting(string key)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            string xPath = "/configuration/appSettings//add[@key='" + key + "']";
							 | 
						|||
| 
								 | 
							
								            XmlDocument doc = new XmlDocument();
							 | 
						|||
| 
								 | 
							
								            string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
							 | 
						|||
| 
								 | 
							
								            doc.Load(exeFileName + ".dll.config");
							 | 
						|||
| 
								 | 
							
								            XmlNode node = doc.SelectSingleNode(xPath);
							 | 
						|||
| 
								 | 
							
								            return node.Attributes["value"].Value.ToString();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |