LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SolverEnvironmentVariableDefinition.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
4
6
7/// <summary>
8/// Describes a solver-specific environment variable that may
9/// identify an installation directory, native library path, or
10/// license location.
11/// </summary>
12[Serializable]
13[XmlType(TypeName = "solverEnvironmentVariableDefinition")]
15{
16 /// <summary>
17 /// Initializes an empty environment-variable definition.
18 /// </summary>
20 {
22 string.Empty;
23
25 string.Empty;
26
28 SolverKind.Unknown;
29 }
30
31 /// <summary>
32 /// Initializes an environment-variable definition.
33 /// </summary>
34 /// <param name="solverKind">
35 /// Solver associated with the variable.
36 /// </param>
37 /// <param name="variableName">
38 /// Environment-variable name.
39 /// </param>
40 /// <param name="description">
41 /// Human-readable description.
42 /// </param>
44 SolverKind solverKind,
45 string variableName,
46 string description)
47 : this()
48 {
50 solverKind;
51
53 variableName;
54
56 description;
57
59 }
60
61 /// <summary>
62 /// Gets or sets the solver associated with the variable.
63 /// </summary>
64 [XmlAttribute("solverKind")]
66 {
67 get;
68 set;
69 }
70
71 /// <summary>
72 /// Gets or sets the environment-variable name.
73 /// </summary>
74 [XmlAttribute("variableName")]
75 public string VariableName
76 {
77 get;
78 set;
79 }
80
81 /// <summary>
82 /// Gets or sets a human-readable description.
83 /// </summary>
84 [XmlElement("description")]
85 public string Description
86 {
87 get;
88 set;
89 }
90
91 /// <summary>
92 /// Gets or sets a value indicating whether the variable is
93 /// expected to contain a license location rather than an
94 /// installation path.
95 /// </summary>
96 [XmlAttribute("isLicenseVariable")]
98 {
99 get;
100 set;
101 }
102
103 /// <summary>
104 /// Gets or sets the discovery priority associated with the
105 /// variable.
106 /// </summary>
107 /// <remarks>
108 /// Lower values represent higher priority.
109 /// </remarks>
110 [XmlAttribute("priority")]
111 public int Priority
112 {
113 get;
114 set;
115 }
116
117 /// <summary>
118 /// Validates the environment-variable definition.
119 /// </summary>
120 /// <exception cref="InvalidOperationException">
121 /// Thrown when required metadata is missing or invalid.
122 /// </exception>
123 public void EnsureValid()
124 {
125 if (SolverKind is
126 SolverKind.Unknown or
127 SolverKind.Automatic)
128 {
129 throw new InvalidOperationException(
130 "An environment-variable definition must " +
131 "target a concrete solver kind.");
132 }
133
134 if (string.IsNullOrWhiteSpace(
136 {
137 throw new InvalidOperationException(
138 "An environment-variable name is required.");
139 }
140
141 if (Priority < 0)
142 {
143 throw new InvalidOperationException(
144 "An environment-variable priority cannot be " +
145 "negative.");
146 }
147 }
148}
bool IsLicenseVariable
Gets or sets a value indicating whether the variable is expected to contain a license location rather...
SolverEnvironmentVariableDefinition(SolverKind solverKind, string variableName, string description)
Initializes an environment-variable definition.
int Priority
Gets or sets the discovery priority associated with the variable.
SolverKind SolverKind
Gets or sets the solver associated with the variable.
SolverEnvironmentVariableDefinition()
Initializes an empty environment-variable definition.