/// <summary> /// 获取配置文件中 PathServiceConfig.config /// </summary> /// <returns></returns> public static PathServiceConfig GetPathServiceConfig() { PathServiceConfig pathServiceConfig = ConfigurationManager.GetSection("PathServiceConfig") as PathServiceConfig; if (pathServiceConfig == null || pathServiceConfig.Equals(new PathServiceConfig())) { throw new Exception("没有配置节点:PathServiceConfig"); } return(pathServiceConfig); }
private void btnGetContent_Click(object sender, EventArgs e) { PathServiceConfig pathConfig = ConfigManager.GetPathServiceConfig(); this.ltbContent.Items.Add("读取配置文件中的信息:"); this.ltbContent.Items.Add(pathConfig.Host); for (int i = 0; i < pathConfig.PathMaps.Count; i++) { PathMap pathMap = pathConfig.PathMaps[i]; this.ltbContent.Items.Add(" --" + pathMap.Name + " " + pathMap.Source + " " + pathMap.Destination); } this.ltbContent.Items.Add(""); }