/// <summary> /// Change the current environment /// </summary> public static void SetCurrent(string name, string suffix, string database) { // determines the current item selected in the envList var envList = GetList; _currentEnv = envList.FirstOrDefault(environnement => environnement.Name.EqualsCi(name ?? Config.Instance.EnvName) && environnement.Suffix.EqualsCi(suffix ?? Config.Instance.EnvSuffix)); if (_currentEnv == null) { _currentEnv = envList.FirstOrDefault(environnement => environnement.Name.EqualsCi(name ?? Config.Instance.EnvName)); } if (_currentEnv == null) { _currentEnv = envList.Count > 0 ? envList[0] : new ProEnvironmentObject(); } Config.Instance.EnvName = _currentEnv.Name; Config.Instance.EnvSuffix = _currentEnv.Suffix; // set database if (!string.IsNullOrEmpty(database) && _currentEnv.DbConnectionInfo.ContainsKey(database)) { _currentEnv.CurrentDb = database; } if (OnEnvironmentChange != null) { OnEnvironmentChange(); } }
/// <summary> /// To create a hard copy of this object /// </summary> public ProEnvironmentObject(ProEnvironmentObject toCopy) { Name = toCopy.Name; Suffix = toCopy.Suffix; Label = toCopy.Label; DbConnectionInfo = toCopy.DbConnectionInfo; ExtraPf = toCopy.ExtraPf; IniPath = toCopy.IniPath; ExtraProPath = toCopy.ExtraProPath; BaseLocalPath = toCopy.BaseLocalPath; BaseCompilationPath = toCopy.BaseCompilationPath; ProwinPath = toCopy.ProwinPath; CmdLineParameters = toCopy.CmdLineParameters; LogFilePath = toCopy.LogFilePath; CompileLocally = toCopy.CompileLocally; CompileWithListing = toCopy.CompileWithListing; _currentProPathDirList = toCopy._currentProPathDirList; // deployer copy _deployer = new Deployer(this, toCopy.Deployer); }
/// <summary> /// To create a hard copy of this object /// </summary> public ProEnvironmentObject(ProEnvironmentObject toCopy) { Name = toCopy.Name; Suffix = toCopy.Suffix; Label = toCopy.Label; DbConnectionInfo = toCopy.DbConnectionInfo; CurrentDb = toCopy.CurrentDb; ExtraPf = toCopy.ExtraPf; IniPath = toCopy.IniPath; ExtraProPath = toCopy.ExtraProPath; BaseLocalPath = toCopy.BaseLocalPath; BaseCompilationPath = toCopy.BaseCompilationPath; ProwinPath = toCopy.ProwinPath; CmdLineParameters = toCopy.CmdLineParameters; LogFilePath = toCopy.LogFilePath; CompileLocally = toCopy.CompileLocally; PostExecutionProgram = toCopy.PostExecutionProgram; PreExecutionProgram = toCopy.PreExecutionProgram; _currentProPathDirList = toCopy._currentProPathDirList; // deployer copy _deployer = toCopy.Deployer; }
/// <summary> /// Saves an environment either by creating a new one (before == null) or /// replacing an old one /// </summary> /// <param name="before"></param> /// <param name="after"></param> public static void Modify(ProEnvironmentObject before, ProEnvironmentObject after) { if (before != null) { var index = _listOfEnv.FindIndex(environnement => environnement.Name.EqualsCi(before.Name) && environnement.Suffix.EqualsCi(before.Suffix)); if (index > -1) { _listOfEnv.RemoveAt(index); } } _listOfEnv.Add(after); SetCurrent(after.Name, after.Suffix, null); }
/// <summary> /// To call when the .xml file has changed and you want to reload it /// </summary> public static void Import() { _listOfEnv.Clear(); _currentEnv = null; Current.ReComputeProPath(); }