Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2956_apriori_knowledge/HeuristicLab.Problems.ExternalEvaluation.Scilab/3.3/Plugin.cs.frame @ 16455

Last change on this file since 16455 was 15589, checked in by swagner, 7 years ago

#2640: Merged r15587 from stable back into trunk

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.PluginInfrastructure;
24using Microsoft.Win32;
25
26namespace HeuristicLab.Problems.ExternalEvaluation.Scilab {
27  /// <summary>
28  /// Plugin class for HeuristicLab.Problems.ExternalEvaluation.Scilab plugin.
29  /// </summary>
30  [Plugin("HeuristicLab.Problems.ExternalEvaluation.Scilab", "3.3.15.$WCREV$")]
31  [PluginFile("HeuristicLab.Problems.ExternalEvaluation.Scilab-3.3.dll", PluginFileType.Assembly)]
32  [PluginDependency("HeuristicLab.DotNetScilab", "1.0")]
33  [PluginDependency("HeuristicLab.Collections", "3.3")]
34  [PluginDependency("HeuristicLab.Common", "3.3")]
35  [PluginDependency("HeuristicLab.Core", "3.3")]
36  [PluginDependency("HeuristicLab.Data", "3.3")]
37  [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
38  [PluginDependency("HeuristicLab.Operators", "3.3")]
39  [PluginDependency("HeuristicLab.Parameters", "3.3")]
40  [PluginDependency("HeuristicLab.Persistence", "3.3")]
41  [PluginDependency("HeuristicLab.Problems.ParameterOptimization", "3.3")]
42  public class HeuristicLabProblemsExternalEvaluationScilabPlugin : PluginBase {
43    private const string registryKey = @"SOFTWARE\Scilab";
44    private const string scilab_Install = @"LASTINSTALL";
45    private const string scilab_PATH = @"SCIPATH";
46
47    public override void OnLoad() {
48      base.OnLoad();
49
50      var currentPath = Environment.GetEnvironmentVariable("path");
51      if (currentPath == null) return;
52
53      var scilabPath = GetScilabInstallPath();
54      if (string.IsNullOrEmpty(scilabPath)) return;
55
56      Environment.SetEnvironmentVariable("path", scilabPath + ";" + currentPath);
57    }
58
59    private string GetScilabInstallPath() {
60      using (var registryLocalMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default)) {
61        using (var registryScilab = registryLocalMachine.OpenSubKey(registryKey)) {
62          if (registryScilab == null) return string.Empty;
63          var scilabVersion = registryScilab.GetValue(scilab_Install);
64          if (scilabVersion == null) return string.Empty;
65          using (var registryScilabVersion = registryScilab.OpenSubKey(scilabVersion.ToString())) {
66            if (registryScilabVersion == null) return string.Empty;
67            var scilabPath = registryScilabVersion.GetValue(scilab_PATH);
68            if (scilabPath == null) return string.Empty;
69            string path = scilabPath.ToString();
70            path += @"\bin";
71            return path;
72          }
73        }
74      }
75    }
76  }
77}
Note: See TracBrowser for help on using the repository browser.