LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SolverDiscoveryCandidate.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
4
6
7/// <summary>
8/// Represents one candidate solver installation or adapter
9/// location discovered on the current computer.
10/// </summary>
11[Serializable]
12[XmlType(TypeName = "solverDiscoveryCandidate")]
13public sealed class SolverDiscoveryCandidate
14{
15 /// <summary>
16 /// Initializes an empty solver-discovery candidate.
17 /// </summary>
19 {
20 Path =
21 string.Empty;
22
24 string.Empty;
25
27 string.Empty;
28
29 Source =
31
33 SolverKind.Unknown;
34 }
35
36 /// <summary>
37 /// Gets or sets the solver kind associated with the
38 /// candidate.
39 /// </summary>
40 [XmlAttribute("solverKind")]
42 {
43 get;
44 set;
45 }
46
47 /// <summary>
48 /// Gets or sets the discovery source.
49 /// </summary>
50 [XmlAttribute("source")]
52 {
53 get;
54 set;
55 }
56
57 /// <summary>
58 /// Gets or sets the discovered directory, assembly,
59 /// native-library, or executable path.
60 /// </summary>
61 [XmlElement("path")]
62 public string Path
63 {
64 get;
65 set;
66 }
67
68 /// <summary>
69 /// Gets or sets a human-readable description of the
70 /// candidate.
71 /// </summary>
72 [XmlElement("description")]
73 public string Description
74 {
75 get;
76 set;
77 }
78
79 /// <summary>
80 /// Gets or sets an optional solver-version hint inferred
81 /// from the discovered path or file metadata.
82 /// </summary>
83 [XmlElement("versionHint")]
84 public string VersionHint
85 {
86 get;
87 set;
88 }
89
90 /// <summary>
91 /// Gets or sets the priority assigned to the candidate.
92 /// </summary>
93 /// <remarks>
94 /// Lower values represent higher priority.
95 /// </remarks>
96 [XmlAttribute("priority")]
97 public int Priority
98 {
99 get;
100 set;
101 }
102
103 /// <summary>
104 /// Gets or sets a value indicating whether the candidate
105 /// path currently exists.
106 /// </summary>
107 [XmlAttribute("exists")]
108 public bool Exists
109 {
110 get;
111 set;
112 }
113
114 /// <summary>
115 /// Validates the discovery candidate.
116 /// </summary>
117 /// <exception cref="InvalidOperationException">
118 /// Thrown when required information is missing or invalid.
119 /// </exception>
120 public void EnsureValid()
121 {
122 if (SolverKind is
123 SolverKind.Unknown or
124 SolverKind.Automatic)
125 {
126 throw new InvalidOperationException(
127 "A discovery candidate must target a concrete " +
128 "solver kind.");
129 }
130
131 if (Source ==
132 SolverDiscoverySource.Unknown)
133 {
134 throw new InvalidOperationException(
135 "A discovery source is required.");
136 }
137
138 if (string.IsNullOrWhiteSpace(
139 Path))
140 {
141 throw new InvalidOperationException(
142 "A discovery candidate path is required.");
143 }
144
145 if (Priority < 0)
146 {
147 throw new InvalidOperationException(
148 "A discovery candidate priority cannot be " +
149 "negative.");
150 }
151 }
152}
string Description
Gets or sets a human-readable description of the candidate.
string VersionHint
Gets or sets an optional solver-version hint inferred from the discovered path or file metadata.
SolverDiscoveryCandidate()
Initializes an empty solver-discovery candidate.
int Priority
Gets or sets the priority assigned to the candidate.
SolverKind SolverKind
Gets or sets the solver kind associated with the candidate.
string Path
Gets or sets the discovered directory, assembly, native-library, or executable path.
SolverDiscoverySource Source
Gets or sets the discovery source.
bool Exists
Gets or sets a value indicating whether the candidate path currently exists.
SolverDiscoverySource
Identifies how a solver installation or adapter location was discovered.