private void BuildSessionParam() { this.BuildLocalWorkParameter(); this.BuildLocalSafetyParameter(); var result = new List <Tuple <IEnumerable <UdpParameters>, SessionConfig> >(); var index = 1; while (index <= 1000) { var section = string.Format("Remote{0}", index++); var keys = _iniFile.ReadValue(section, null); if (string.IsNullOrEmpty(keys)) { continue; } // Read CustomNodeCode。 var customNodeCode = (ushort)SettingsParser.ParseDecimal(_iniFile.ReadValue(section, "CustomNodeCode")); // LoalPort var ports = _iniFile.ReadValue(section, "LocalPort").Trim().Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (ports.Count < 1) { throw new Exception(string.Format("{0}.LocalPort个数不能小于1。", section)); } int localRedPort = 0, localBluePort = 0; localRedPort = (int)SettingsParser.ParseDecimal(ports[0]); localBluePort = ports.Count < 2 ? localRedPort : (int)SettingsParser.ParseDecimal(ports[1]); // Create Remote EndPoint var remoteEP = SettingsParser.ParseIPEndPoints(_iniFile.ReadValue(section, "RemoteEndPoints"), new string[] { ",", "," }); if (remoteEP.Count < 2) { throw new Exception(string.Format("{0}.RemoteEndPoints个数不能小于2。", section)); } // Create UdpParam. var udpParam = this.CreateUdpParameters(localRedPort, localBluePort, remoteEP[0], remoteEP[1]); // Create Remote SafetyParamters var remoteSafetyParam = this.CreateRemoteSafetyParameters(section); // var sessionCfg = new SessionConfig(this.LocalWorkParameter, this.LocalSafetyParam, remoteSafetyParam, customNodeCode); var sessionParam = new Tuple <IEnumerable <UdpParameters>, SessionConfig>(udpParam, sessionCfg); result.Add(sessionParam); } ; this.SessionParam = result; }