public bool AddServer(string config, string mark, bool quiet = false) { // first check if (IsServerExist(config)) { return(false); } var coreInfo = new VgcApis.Models.Datas.CoreInfo { foldingLevel = setting.CustomDefImportIsFold ? 1 : 0, isInjectImport = setting.CustomDefImportGlobalImport, isInjectSkipCNSite = setting.CustomDefImportBypassCnSite, customInbType = setting.CustomDefImportMode, inbIp = setting.CustomDefImportIp, inbPort = setting.CustomDefImportPort, config = config, customMark = mark, }; var newServer = new Controller.CoreServerCtrl(coreInfo); newServer.Run(cache, setting, configMgr, this); bool duplicated = true; lock (serverListWriteLock) { // double check if (!IsServerExist(config)) { coreServList.Add(newServer); duplicated = false; } } if (duplicated) { newServer.Dispose(); return(false); } BindEventsTo(newServer); if (!quiet) { newServer.GetConfiger().UpdateSummaryThen(() => { // UpdateSummaryThen will invoke OnServerPropertyChange. InvokeEventOnServerCountChange(this, EventArgs.Empty); RequireFormMainUpdate(); }); } setting.LazyGC(); serverSaver.DoItLater(); return(true); }
public bool AddServer(string config, string mark, bool quiet = false) { // first check if (IsServerExist(config)) { return(false); } var newServer = new Controller.CoreServerCtrl( new VgcApis.Models.Datas.CoreInfo { customInbType = setting.CustomDefImportMode, inbIp = setting.CustomDefImportIp, inbPort = setting.CustomDefImportPort, config = config, customMark = mark, }); newServer.Run(cache, setting, configMgr, this); bool duplicated = true; lock (serverListWriteLock) { // double check if (!IsServerExist(config)) { coreServList.Add(newServer); duplicated = false; } } if (duplicated) { newServer.Dispose(); return(false); } BindEventsTo(newServer); if (!quiet) { newServer.GetConfiger().UpdateSummaryThen(() => { InvokeEventOnRequireMenuUpdate(this, EventArgs.Empty); RequireFormMainUpdate(); }); } setting.LazyGC(); serverSaver.DoItLater(); return(true); }