@@ -176,6 +176,112 @@ public static Acceleration FromNanometerPerSecondSquared(double nanometerperseco
176
176
}
177
177
178
178
179
+ /// <summary>
180
+ /// Get nullable Acceleration from nullable CentimeterPerSecondSquared.
181
+ /// </summary>
182
+ public static Acceleration ? FromCentimeterPerSecondSquared ( double ? centimeterpersecondsquared )
183
+ {
184
+ if ( centimeterpersecondsquared . HasValue )
185
+ {
186
+ return FromCentimeterPerSecondSquared ( centimeterpersecondsquared . Value ) ;
187
+ }
188
+ else
189
+ {
190
+ return null ;
191
+ }
192
+ }
193
+
194
+ /// <summary>
195
+ /// Get nullable Acceleration from nullable DecimeterPerSecondSquared.
196
+ /// </summary>
197
+ public static Acceleration ? FromDecimeterPerSecondSquared ( double ? decimeterpersecondsquared )
198
+ {
199
+ if ( decimeterpersecondsquared . HasValue )
200
+ {
201
+ return FromDecimeterPerSecondSquared ( decimeterpersecondsquared . Value ) ;
202
+ }
203
+ else
204
+ {
205
+ return null ;
206
+ }
207
+ }
208
+
209
+ /// <summary>
210
+ /// Get nullable Acceleration from nullable KilometerPerSecondSquared.
211
+ /// </summary>
212
+ public static Acceleration ? FromKilometerPerSecondSquared ( double ? kilometerpersecondsquared )
213
+ {
214
+ if ( kilometerpersecondsquared . HasValue )
215
+ {
216
+ return FromKilometerPerSecondSquared ( kilometerpersecondsquared . Value ) ;
217
+ }
218
+ else
219
+ {
220
+ return null ;
221
+ }
222
+ }
223
+
224
+ /// <summary>
225
+ /// Get nullable Acceleration from nullable MeterPerSecondSquared.
226
+ /// </summary>
227
+ public static Acceleration ? FromMeterPerSecondSquared ( double ? meterpersecondsquared )
228
+ {
229
+ if ( meterpersecondsquared . HasValue )
230
+ {
231
+ return FromMeterPerSecondSquared ( meterpersecondsquared . Value ) ;
232
+ }
233
+ else
234
+ {
235
+ return null ;
236
+ }
237
+ }
238
+
239
+ /// <summary>
240
+ /// Get nullable Acceleration from nullable MicrometerPerSecondSquared.
241
+ /// </summary>
242
+ public static Acceleration ? FromMicrometerPerSecondSquared ( double ? micrometerpersecondsquared )
243
+ {
244
+ if ( micrometerpersecondsquared . HasValue )
245
+ {
246
+ return FromMicrometerPerSecondSquared ( micrometerpersecondsquared . Value ) ;
247
+ }
248
+ else
249
+ {
250
+ return null ;
251
+ }
252
+ }
253
+
254
+ /// <summary>
255
+ /// Get nullable Acceleration from nullable MillimeterPerSecondSquared.
256
+ /// </summary>
257
+ public static Acceleration ? FromMillimeterPerSecondSquared ( double ? millimeterpersecondsquared )
258
+ {
259
+ if ( millimeterpersecondsquared . HasValue )
260
+ {
261
+ return FromMillimeterPerSecondSquared ( millimeterpersecondsquared . Value ) ;
262
+ }
263
+ else
264
+ {
265
+ return null ;
266
+ }
267
+ }
268
+
269
+ /// <summary>
270
+ /// Get nullable Acceleration from nullable NanometerPerSecondSquared.
271
+ /// </summary>
272
+ public static Acceleration ? FromNanometerPerSecondSquared ( double ? nanometerpersecondsquared )
273
+ {
274
+ if ( nanometerpersecondsquared . HasValue )
275
+ {
276
+ return FromNanometerPerSecondSquared ( nanometerpersecondsquared . Value ) ;
277
+ }
278
+ else
279
+ {
280
+ return null ;
281
+ }
282
+ }
283
+
284
+
179
285
/// <summary>
180
286
/// Dynamically convert from value and unit enum <see cref="AccelerationUnit" /> to <see cref="Acceleration" />.
181
287
/// </summary>
@@ -206,6 +312,40 @@ public static Acceleration From(double value, AccelerationUnit fromUnit)
206
312
}
207
313
}
208
314
315
+ /// <summary>
316
+ /// Dynamically convert from value and unit enum <see cref="AccelerationUnit" /> to <see cref="Acceleration" />.
317
+ /// </summary>
318
+ /// <param name="value">Value to convert from.</param>
319
+ /// <param name="fromUnit">Unit to convert from.</param>
320
+ /// <returns>Acceleration unit value.</returns>
321
+ public static Acceleration ? From ( double ? value , AccelerationUnit fromUnit )
322
+ {
323
+ if ( ! value . HasValue )
324
+ {
325
+ return null ;
326
+ }
327
+ switch ( fromUnit )
328
+ {
329
+ case AccelerationUnit . CentimeterPerSecondSquared :
330
+ return FromCentimeterPerSecondSquared ( value . Value ) ;
331
+ case AccelerationUnit . DecimeterPerSecondSquared :
332
+ return FromDecimeterPerSecondSquared ( value . Value ) ;
333
+ case AccelerationUnit . KilometerPerSecondSquared :
334
+ return FromKilometerPerSecondSquared ( value . Value ) ;
335
+ case AccelerationUnit . MeterPerSecondSquared :
336
+ return FromMeterPerSecondSquared ( value . Value ) ;
337
+ case AccelerationUnit . MicrometerPerSecondSquared :
338
+ return FromMicrometerPerSecondSquared ( value . Value ) ;
339
+ case AccelerationUnit . MillimeterPerSecondSquared :
340
+ return FromMillimeterPerSecondSquared ( value . Value ) ;
341
+ case AccelerationUnit . NanometerPerSecondSquared :
342
+ return FromNanometerPerSecondSquared ( value . Value ) ;
343
+
344
+ default :
345
+ throw new NotImplementedException ( "fromUnit: " + fromUnit ) ;
346
+ }
347
+ }
348
+
209
349
/// <summary>
210
350
/// Get unit abbreviation string.
211
351
/// </summary>
@@ -371,14 +511,14 @@ public double As(AccelerationUnit unit)
371
511
/// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in"
372
512
/// </exception>
373
513
/// <exception cref="AmbiguousUnitParseException">
374
- /// More than one unit is represented by the specified unit abbreviation.
375
- /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of
376
- /// <see cref="VolumeUnit.MetricCup" />, <see cref="VolumeUnit.UsLegalCup" /> and <see cref="VolumeUnit.UsCustomaryCup" />.
514
+ /// More than one unit is represented by the specified unit abbreviation.
515
+ /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of
516
+ /// <see cref="VolumeUnit.MetricCup" />, <see cref="VolumeUnit.UsLegalCup" /> and <see cref="VolumeUnit.UsCustomaryCup" />.
377
517
/// </exception>
378
518
/// <exception cref="UnitsNetException">
379
- /// If anything else goes wrong, typically due to a bug or unhandled case.
380
- /// We wrap exceptions in <see cref="UnitsNetException" /> to allow you to distinguish
381
- /// Units.NET exceptions from other exceptions.
519
+ /// If anything else goes wrong, typically due to a bug or unhandled case.
520
+ /// We wrap exceptions in <see cref="UnitsNetException" /> to allow you to distinguish
521
+ /// Units.NET exceptions from other exceptions.
382
522
/// </exception>
383
523
public static Acceleration Parse ( string str , IFormatProvider formatProvider = null )
384
524
{
0 commit comments