LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SolverInstallationPathDefinition.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
4
6
7/// <summary>
8/// Describes a conventional installation path that may contain
9/// a supported solver.
10/// </summary>
11[Serializable]
12[XmlType(TypeName = "solverInstallationPathDefinition")]
14{
15 /// <summary>
16 /// Initializes an empty installation-path definition.
17 /// </summary>
19 {
21 string.Empty;
22
24 string.Empty;
25
27 SolverKind.Unknown;
28 }
29
30 /// <summary>
31 /// Initializes an installation-path definition.
32 /// </summary>
33 /// <param name="solverKind">
34 /// Solver associated with the path.
35 /// </param>
36 /// <param name="pathPattern">
37 /// Absolute path or path pattern to inspect.
38 /// </param>
39 /// <param name="description">
40 /// Human-readable description.
41 /// </param>
43 SolverKind solverKind,
44 string pathPattern,
45 string description)
46 : this()
47 {
49 solverKind;
50
52 pathPattern;
53
55 description;
56
58 }
59
60 /// <summary>
61 /// Gets or sets the solver associated with the path.
62 /// </summary>
63 [XmlAttribute("solverKind")]
65 {
66 get;
67 set;
68 }
69
70 /// <summary>
71 /// Gets or sets the installation path or path pattern.
72 /// </summary>
73 /// <remarks>
74 /// The pattern may contain environment-variable
75 /// placeholders such as <c>%ProgramFiles%</c>.
76 /// </remarks>
77 [XmlElement("pathPattern")]
78 public string PathPattern
79 {
80 get;
81 set;
82 }
83
84 /// <summary>
85 /// Gets or sets a human-readable description.
86 /// </summary>
87 [XmlElement("description")]
88 public string Description
89 {
90 get;
91 set;
92 }
93
94 /// <summary>
95 /// Gets or sets the discovery priority associated with the
96 /// path.
97 /// </summary>
98 /// <remarks>
99 /// Lower values represent higher priority.
100 /// </remarks>
101 [XmlAttribute("priority")]
102 public int Priority
103 {
104 get;
105 set;
106 }
107
108 /// <summary>
109 /// Gets or sets a value indicating whether subdirectories
110 /// should be searched recursively.
111 /// </summary>
112 [XmlAttribute("recursiveSearch")]
113 public bool RecursiveSearch
114 {
115 get;
116 set;
117 }
118
119 /// <summary>
120 /// Gets or sets an optional file name expected below the
121 /// installation path.
122 /// </summary>
123 [XmlElement("expectedFileName")]
124 public string ExpectedFileName
125 {
126 get;
127 set;
128 } =
129 string.Empty;
130
131 /// <summary>
132 /// Validates the installation-path definition.
133 /// </summary>
134 /// <exception cref="InvalidOperationException">
135 /// Thrown when required metadata is missing or invalid.
136 /// </exception>
137 public void EnsureValid()
138 {
139 if (SolverKind is
140 SolverKind.Unknown or
141 SolverKind.Automatic)
142 {
143 throw new InvalidOperationException(
144 "An installation-path definition must target " +
145 "a concrete solver kind.");
146 }
147
148 if (string.IsNullOrWhiteSpace(
150 {
151 throw new InvalidOperationException(
152 "An installation path or path pattern is " +
153 "required.");
154 }
155
156 if (Priority < 0)
157 {
158 throw new InvalidOperationException(
159 "An installation-path priority cannot be " +
160 "negative.");
161 }
162 }
163}
int Priority
Gets or sets the discovery priority associated with the path.
SolverKind SolverKind
Gets or sets the solver associated with the path.
SolverInstallationPathDefinition()
Initializes an empty installation-path definition.
bool RecursiveSearch
Gets or sets a value indicating whether subdirectories should be searched recursively.
SolverInstallationPathDefinition(SolverKind solverKind, string pathPattern, string description)
Initializes an installation-path definition.
string ExpectedFileName
Gets or sets an optional file name expected below the installation path.
string PathPattern
Gets or sets the installation path or path pattern.