42
42
using System . Text . RegularExpressions ;
43
43
using System . Linq ;
44
44
using JetBrains . Annotations ;
45
+ using UnitsNet . InternalHelpers ;
45
46
using UnitsNet . Units ;
46
47
47
48
// ReSharper disable once CheckNamespace
@@ -88,6 +89,7 @@ static AmountOfSubstance()
88
89
/// <param name="numericValue">The numeric value to contruct this quantity with.</param>
89
90
/// <param name="unit">The unit representation to contruct this quantity with.</param>
90
91
/// <remarks>Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.</remarks>
92
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
91
93
#if WINDOWS_UWP
92
94
private
93
95
#else
@@ -98,7 +100,7 @@ static AmountOfSubstance()
98
100
if ( unit == AmountOfSubstanceUnit . Undefined )
99
101
throw new ArgumentException ( "The quantity can not be created with an undefined unit." , nameof ( unit ) ) ;
100
102
101
- _value = numericValue ;
103
+ _value = Guard . EnsureValidNumber ( numericValue , nameof ( numericValue ) ) ;
102
104
_unit = unit ;
103
105
}
104
106
@@ -209,6 +211,7 @@ public static BaseDimensions BaseDimensions
209
211
/// <summary>
210
212
/// Get AmountOfSubstance from Centimoles.
211
213
/// </summary>
214
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
212
215
#if WINDOWS_UWP
213
216
[ Windows . Foundation . Metadata . DefaultOverload ]
214
217
public static AmountOfSubstance FromCentimoles ( double centimoles )
@@ -223,6 +226,7 @@ public static AmountOfSubstance FromCentimoles(QuantityValue centimoles)
223
226
/// <summary>
224
227
/// Get AmountOfSubstance from CentipoundMoles.
225
228
/// </summary>
229
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
226
230
#if WINDOWS_UWP
227
231
[ Windows . Foundation . Metadata . DefaultOverload ]
228
232
public static AmountOfSubstance FromCentipoundMoles ( double centipoundmoles )
@@ -237,6 +241,7 @@ public static AmountOfSubstance FromCentipoundMoles(QuantityValue centipoundmole
237
241
/// <summary>
238
242
/// Get AmountOfSubstance from Decimoles.
239
243
/// </summary>
244
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
240
245
#if WINDOWS_UWP
241
246
[ Windows . Foundation . Metadata . DefaultOverload ]
242
247
public static AmountOfSubstance FromDecimoles ( double decimoles )
@@ -251,6 +256,7 @@ public static AmountOfSubstance FromDecimoles(QuantityValue decimoles)
251
256
/// <summary>
252
257
/// Get AmountOfSubstance from DecipoundMoles.
253
258
/// </summary>
259
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
254
260
#if WINDOWS_UWP
255
261
[ Windows . Foundation . Metadata . DefaultOverload ]
256
262
public static AmountOfSubstance FromDecipoundMoles ( double decipoundmoles )
@@ -265,6 +271,7 @@ public static AmountOfSubstance FromDecipoundMoles(QuantityValue decipoundmoles)
265
271
/// <summary>
266
272
/// Get AmountOfSubstance from Kilomoles.
267
273
/// </summary>
274
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
268
275
#if WINDOWS_UWP
269
276
[ Windows . Foundation . Metadata . DefaultOverload ]
270
277
public static AmountOfSubstance FromKilomoles ( double kilomoles )
@@ -279,6 +286,7 @@ public static AmountOfSubstance FromKilomoles(QuantityValue kilomoles)
279
286
/// <summary>
280
287
/// Get AmountOfSubstance from KilopoundMoles.
281
288
/// </summary>
289
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
282
290
#if WINDOWS_UWP
283
291
[ Windows . Foundation . Metadata . DefaultOverload ]
284
292
public static AmountOfSubstance FromKilopoundMoles ( double kilopoundmoles )
@@ -293,6 +301,7 @@ public static AmountOfSubstance FromKilopoundMoles(QuantityValue kilopoundmoles)
293
301
/// <summary>
294
302
/// Get AmountOfSubstance from Micromoles.
295
303
/// </summary>
304
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
296
305
#if WINDOWS_UWP
297
306
[ Windows . Foundation . Metadata . DefaultOverload ]
298
307
public static AmountOfSubstance FromMicromoles ( double micromoles )
@@ -307,6 +316,7 @@ public static AmountOfSubstance FromMicromoles(QuantityValue micromoles)
307
316
/// <summary>
308
317
/// Get AmountOfSubstance from MicropoundMoles.
309
318
/// </summary>
319
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
310
320
#if WINDOWS_UWP
311
321
[ Windows . Foundation . Metadata . DefaultOverload ]
312
322
public static AmountOfSubstance FromMicropoundMoles ( double micropoundmoles )
@@ -321,6 +331,7 @@ public static AmountOfSubstance FromMicropoundMoles(QuantityValue micropoundmole
321
331
/// <summary>
322
332
/// Get AmountOfSubstance from Millimoles.
323
333
/// </summary>
334
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
324
335
#if WINDOWS_UWP
325
336
[ Windows . Foundation . Metadata . DefaultOverload ]
326
337
public static AmountOfSubstance FromMillimoles ( double millimoles )
@@ -335,6 +346,7 @@ public static AmountOfSubstance FromMillimoles(QuantityValue millimoles)
335
346
/// <summary>
336
347
/// Get AmountOfSubstance from MillipoundMoles.
337
348
/// </summary>
349
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
338
350
#if WINDOWS_UWP
339
351
[ Windows . Foundation . Metadata . DefaultOverload ]
340
352
public static AmountOfSubstance FromMillipoundMoles ( double millipoundmoles )
@@ -349,6 +361,7 @@ public static AmountOfSubstance FromMillipoundMoles(QuantityValue millipoundmole
349
361
/// <summary>
350
362
/// Get AmountOfSubstance from Moles.
351
363
/// </summary>
364
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
352
365
#if WINDOWS_UWP
353
366
[ Windows . Foundation . Metadata . DefaultOverload ]
354
367
public static AmountOfSubstance FromMoles ( double moles )
@@ -363,6 +376,7 @@ public static AmountOfSubstance FromMoles(QuantityValue moles)
363
376
/// <summary>
364
377
/// Get AmountOfSubstance from Nanomoles.
365
378
/// </summary>
379
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
366
380
#if WINDOWS_UWP
367
381
[ Windows . Foundation . Metadata . DefaultOverload ]
368
382
public static AmountOfSubstance FromNanomoles ( double nanomoles )
@@ -377,6 +391,7 @@ public static AmountOfSubstance FromNanomoles(QuantityValue nanomoles)
377
391
/// <summary>
378
392
/// Get AmountOfSubstance from NanopoundMoles.
379
393
/// </summary>
394
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
380
395
#if WINDOWS_UWP
381
396
[ Windows . Foundation . Metadata . DefaultOverload ]
382
397
public static AmountOfSubstance FromNanopoundMoles ( double nanopoundmoles )
@@ -391,6 +406,7 @@ public static AmountOfSubstance FromNanopoundMoles(QuantityValue nanopoundmoles)
391
406
/// <summary>
392
407
/// Get AmountOfSubstance from PoundMoles.
393
408
/// </summary>
409
+ /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
394
410
#if WINDOWS_UWP
395
411
[ Windows . Foundation . Metadata . DefaultOverload ]
396
412
public static AmountOfSubstance FromPoundMoles ( double poundmoles )
0 commit comments