国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
WCF修改App.config配置文件技巧分享 - 51CTO.COM

WCF對App.config配置文件的修改方法我們將會通過以下這段代碼為大家詳細(xì)介紹相關(guān)操作方法。希望對于又需要的朋友們能夠從今天介紹的內(nèi)容中獲得一些幫助,來解決他們在實際應(yīng)用中碰到的一些問題。

WCF修改App.config配置文件代碼示例:

  1. using System.ServiceModel.Configuration;using System.Text.
    RegularExpressions;// 修改配置文件  
  2. private void ChanageConfig()  
  3. {  
  4. Configuration config = ConfigurationManager.OpenExeConfiguration
    (Application.ExecutablePath);  
  5. ConfigurationSectionGroup sct = config.SectionGroups
    ["system.serviceModel"];  
  6. ServiceModelSectionGroup serviceModelSectionGroup = 
    sct as ServiceModelSectionGroup;  
  7. ClientSection clientSection = serviceModelSectionGroup.Client;  
  8. foreach (ChannelEndpointElement item in clientSection.Endpoints)  
  9. {  
  10. string pattern = "://.*/";  
  11. string address = item.Address.ToString();  
  12. string replacement = string.Format("://{0}:{1}/", 
    Global.ServerIP, Global.ServerPort);  
  13. address = Regex.Replace(address, pattern, replacement);  
  14. item.Address = new Uri(address);  
  15. }  
  16. config.Save(ConfigurationSaveMode.Modified);  
  17. ConfigurationManager.RefreshSection("system.serviceModel");  
  18. return;  
  19. /*  
  20. Configuration configuration = ConfigurationManager.
    OpenExeConfiguration(ConfigurationUserLevel.None);  
  21. ServiceModelSectionGroup serviceModelSectionGroup = 
    ServiceModelSectionGroup.GetSectionGroup(configuration);  
  22. ClientSection clientSection = serviceModelSectionGroup.Client;  
  23. foreach(ChannelEndpointElement item in clientSection.Endpoints)  
  24. {  
  25. MessageBox.Show(item.Address.Host);  
  26. }  
  27. configuration.Save();  
  28. */  
  29. return;  
  30. XmlDocument xmlDoc = new XmlDocument();  
  31. xmlDoc.Load("Rca.exe.config");  
  32. XmlNodeList nodeList = xmlDoc.SelectSingleNode
    ("configuration/appSettings").ChildNodes;  
  33. foreach (XmlNode node in nodeList)  
  34. {  
  35. switch (node.Attributes["key"].InnerText.ToLower())  
  36. {  
  37. case "serverip":  
  38. node.Attributes["value"].InnerText = Global.ServerIP;  
  39. break;  
  40. case "serverport":  
  41. node.Attributes["value"].InnerText = Global.ServerPort;  
  42. break;  
  43. case "langdataid":  
  44. node.Attributes["value"].InnerText = Global.LangDataID;  
  45. break;  
  46. case "uidataid":  
  47. node.Attributes["value"].InnerText = Global.UIDataID;  
  48. break;  
  49. }  
  50. }  
  51. nodeList = xmlDoc.SelectSingleNode("configuration/
    system.serviceModel/client").ChildNodes;  
  52. foreach (XmlNode node in nodeList)  
  53. {  
  54. string pattern = "://.*/";  
  55. string address = node.Attributes["address"].InnerText;  
  56. string replacement = string.Format("://{0}:{1}/", 
    Global.ServerIP, Global.ServerPort);  
  57. address = Regex.Replace(address, pattern, replacement);  
  58. node.Attributes["address"].InnerText = address;  
  59. if (node.Attributes["contract"].InnerText == "LogicCommon")  
  60. {  
  61. LogicCommonCfgName = node.Attributes["name"].InnerText;  
  62. LogicCommonAddress = node.Attributes["address"].InnerText;  
  63. }  
  64. }  
  65. xmlDoc.Save("Rca.exe.config");  

以上就是我們?yōu)榇蠹医榻B的WCF修改App.config配置文件的全部操作步驟。

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
WCF重寫ServiceHost,實現(xiàn)獨立配置文件
用XML文件保存配置信息的一個類(C#)
通過Cache機(jī)制實現(xiàn)通用的配置管理模塊
【新提醒】【分享序列化腳本~~備忘隨時拿來用~】
在.net界面中修改web.config/app.config配置
Cacti插件詳解——Weathermap
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服