/// <summary> /// Internal Constructor /// </summary> /// <param name="solver"></param> /// <param name="resultStatus"></param> /// <param name="solution"></param> /// <param name="solutionValues"></param> /// <inheritdoc /> public SolutionEventArgs(Solver solver, LinearResultStatus resultStatus, TSolution solution , dynamic solutionValues) { VariableCount = solver.NumVariables(); ConstraintCount = solver.NumConstraints(); ResultStatus = resultStatus; Solution = solution; SolutionValues = solutionValues; }
public TSolution GetSolution <TSolution>() { TSolution result = default; if (!(solutionGetter is Getter <TCase, TSolution> solutionGetterDelegate)) { throw new InvalidOperationException("Encountered incorrect solution getter type."); } solutionGetterDelegate(Data, ref result); return(result); }
/// <summary> /// Initialise the dialog /// </summary> /// <param name="BranchLocation">Current branch location</param> /// <param name="LocalSettings">A reference to the local settings object</param> /// <param name="PreferredIDE">The user's preferred IDE (obtained from the registry)</param> public void Initialise(string BranchLocation, SettingsDictionary LocalSettings, TDevEnvironment PreferredIDE) { // Step 1: Is this an existing branch? bool gotSolutions = false; bool gotExes = false; string searchPath = Path.Combine(BranchLocation, "delivery", "projects", "vs2010"); if (Directory.Exists(searchPath)) { string[] solutionFiles = Directory.GetFiles(searchPath, "*.sln"); gotSolutions = solutionFiles.Length >= 5; } searchPath = Path.Combine(BranchLocation, "delivery", "bin"); if (Directory.Exists(searchPath)) { string[] exeFiles = Directory.GetFiles(searchPath, "Petra*.exe"); gotExes = exeFiles.Length >= 4; } _wasExistingBranch = gotSolutions && gotExes; if (_wasExistingBranch) { this.Text = this.Text.Replace(" a New ", " an Existing "); } // Step 2: initialise the control settings based on our saved settings from last time. // There are separate settings for New and Existing chkGenerateSolution.Checked = _wasExistingBranch ? LocalSettings.EBA_GenerateSolutionOption > 0 : LocalSettings.NBA_GenerateSolutionOption > 0; optFullCompile.Checked = _wasExistingBranch ? LocalSettings.EBA_GenerateSolutionOption <= 1 : LocalSettings.NBA_GenerateSolutionOption <= 1; optMinimalCompile.Checked = _wasExistingBranch ? LocalSettings.EBA_GenerateSolutionOption >= 2 : LocalSettings.NBA_GenerateSolutionOption >= 2; chkCreateConfigFiles.Checked = _wasExistingBranch ? LocalSettings.EBA_CreateMyConfigurations : LocalSettings.NBA_CreateMyConfigurations; chkInitDatabase.Checked = _wasExistingBranch ? LocalSettings.EBA_InitialiseDatabase : LocalSettings.NBA_InitialiseDatabase; chkOpenIDE.Checked = _wasExistingBranch ? LocalSettings.EBA_LaunchIDE : LocalSettings.NBA_LaunchIDE; chkStartServerAndClient.Checked = _wasExistingBranch ? LocalSettings.EBA_StartClient : LocalSettings.NBA_StartClient; chkOpenIDE.Text = "Open the solution in the " + (PreferredIDE == TDevEnvironment.VisualStudio ? "Visual Studio IDE" : "SharpDevelop IDE"); // Step 3. Initialise the database combo box BuildConfiguration DbCfg = new BuildConfiguration(string.Empty, LocalSettings); for (int i = 0;; i++) { string dbms; string dbName; string port; string location; string unused1; bool unused2; string unused3; if (DbCfg.GetStoredConfiguration(i, out dbms, out dbName, out port, out unused1, out unused2, out location, out unused3)) { string portString = port == string.Empty ? port : " on port " + port; string s = string.Format("{0}: {1}{2} [{3}]", dbms, dbName, portString, location == string.Empty ? "local" : location); cboInitialDatabase.Items.Add(s); } else { break; } } int dbIndex = _wasExistingBranch ? LocalSettings.EBA_DatabaseConfiguration : LocalSettings.NBA_DatabaseConfiguration; if ((cboInitialDatabase.Items.Count > 0) && (dbIndex < cboInitialDatabase.Items.Count)) { cboInitialDatabase.SelectedIndex = dbIndex; } // Step 4. Initialise the solutions combo box for (TSolution sln = TSolution.Full; sln <= TSolution.Testing; sln++) { cboSolution.Items.Add(sln); } int slnIndex = _wasExistingBranch ? LocalSettings.EBA_IDESolution : LocalSettings.NBA_IDESolution; if ((slnIndex >= (int)TSolution.Full) && (slnIndex <= (int)TSolution.Testing)) { cboSolution.SelectedIndex = slnIndex; } lblStatus.Visible = false; progressBar.Visible = false; // Finally, keep a reference to the settings so we can save them on exit _localSettings = LocalSettings; }