forked from angularsen/UnitsNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForcePerLength.g.cs
More file actions
1209 lines (1093 loc) · 58.7 KB
/
ForcePerLength.g.cs
File metadata and controls
1209 lines (1093 loc) · 58.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by \generate-code.bat.
//
// Changes to this file will be lost when the code is regenerated.
// The build server regenerates the code before each build and a pre-build
// step will regenerate the code on each local build.
//
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities.
//
// </auto-generated>
//------------------------------------------------------------------------------
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
using System;
using System.Globalization;
using System.Linq;
using JetBrains.Annotations;
using UnitsNet.Units;
using UnitsNet.InternalHelpers;
// ReSharper disable once CheckNamespace
namespace UnitsNet
{
/// <summary>
/// The magnitude of force per unit length.
/// </summary>
// Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
public sealed partial class ForcePerLength : IQuantity
{
/// <summary>
/// The numeric value this quantity was constructed with.
/// </summary>
private readonly double _value;
/// <summary>
/// The unit this quantity was constructed with.
/// </summary>
private readonly ForcePerLengthUnit? _unit;
static ForcePerLength()
{
BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0, 0);
Info = new QuantityInfo(QuantityType.ForcePerLength, Units.Cast<Enum>().ToArray(), BaseUnit, Zero, BaseDimensions);
}
/// <summary>
/// Creates the quantity with a value of 0 in the base unit NewtonPerMeter.
/// </summary>
/// <remarks>
/// Windows Runtime Component requires a default constructor.
/// </remarks>
public ForcePerLength()
{
_value = 0;
_unit = BaseUnit;
}
/// <summary>
/// Creates the quantity with the given numeric value and unit.
/// </summary>
/// <param name="value">The numeric value to construct this quantity with.</param>
/// <param name="unit">The unit representation to construct this quantity with.</param>
/// <remarks>Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.</remarks>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
private ForcePerLength(double value, ForcePerLengthUnit unit)
{
if(unit == ForcePerLengthUnit.Undefined)
throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit));
_value = Guard.EnsureValidNumber(value, nameof(value));
_unit = unit;
}
#region Static Properties
/// <summary>
/// Information about the quantity type, such as unit values and names.
/// </summary>
internal static QuantityInfo Info { get; }
/// <summary>
/// The <see cref="BaseDimensions" /> of this quantity.
/// </summary>
public static BaseDimensions BaseDimensions { get; }
/// <summary>
/// The base unit of ForcePerLength, which is NewtonPerMeter. All conversions go via this value.
/// </summary>
public static ForcePerLengthUnit BaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter;
/// <summary>
/// Represents the largest possible value of ForcePerLength
/// </summary>
public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, BaseUnit);
/// <summary>
/// Represents the smallest possible value of ForcePerLength
/// </summary>
public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, BaseUnit);
/// <summary>
/// The <see cref="QuantityType" /> of this quantity.
/// </summary>
public static QuantityType QuantityType { get; } = QuantityType.ForcePerLength;
/// <summary>
/// All units of measurement for the ForcePerLength quantity.
/// </summary>
public static ForcePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast<ForcePerLengthUnit>().Except(new ForcePerLengthUnit[]{ ForcePerLengthUnit.Undefined }).ToArray();
/// <summary>
/// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerMeter.
/// </summary>
public static ForcePerLength Zero { get; } = new ForcePerLength(0, BaseUnit);
#endregion
#region Properties
/// <summary>
/// The numeric value this quantity was constructed with.
/// </summary>
public double Value => Convert.ToDouble(_value);
/// <inheritdoc cref="IQuantity.Unit"/>
object IQuantity.Unit => Unit;
/// <summary>
/// The unit this quantity was constructed with -or- <see cref="BaseUnit" /> if default ctor was used.
/// </summary>
public ForcePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit);
internal QuantityInfo QuantityInfo => Info;
/// <summary>
/// The <see cref="QuantityType" /> of this quantity.
/// </summary>
public QuantityType Type => ForcePerLength.QuantityType;
/// <summary>
/// The <see cref="BaseDimensions" /> of this quantity.
/// </summary>
public BaseDimensions Dimensions => ForcePerLength.BaseDimensions;
#endregion
#region Conversion Properties
/// <summary>
/// Get ForcePerLength in CentinewtonsPerCentimeter.
/// </summary>
public double CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in CentinewtonsPerMeter.
/// </summary>
public double CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter);
/// <summary>
/// Get ForcePerLength in CentinewtonsPerMillimeter.
/// </summary>
public double CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in DecanewtonsPerCentimeter.
/// </summary>
public double DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in DecanewtonsPerMeter.
/// </summary>
public double DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter);
/// <summary>
/// Get ForcePerLength in DecanewtonsPerMillimeter.
/// </summary>
public double DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in DecinewtonsPerCentimeter.
/// </summary>
public double DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in DecinewtonsPerMeter.
/// </summary>
public double DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter);
/// <summary>
/// Get ForcePerLength in DecinewtonsPerMillimeter.
/// </summary>
public double DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in KilogramsForcePerCentimeter.
/// </summary>
public double KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter);
/// <summary>
/// Get ForcePerLength in KilogramsForcePerMeter.
/// </summary>
public double KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter);
/// <summary>
/// Get ForcePerLength in KilogramsForcePerMillimeter.
/// </summary>
public double KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter);
/// <summary>
/// Get ForcePerLength in KilonewtonsPerCentimeter.
/// </summary>
public double KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in KilonewtonsPerMeter.
/// </summary>
public double KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter);
/// <summary>
/// Get ForcePerLength in KilonewtonsPerMillimeter.
/// </summary>
public double KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in KilopoundsForcePerFoot.
/// </summary>
public double KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot);
/// <summary>
/// Get ForcePerLength in KilopoundsForcePerInch.
/// </summary>
public double KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch);
/// <summary>
/// Get ForcePerLength in MeganewtonsPerCentimeter.
/// </summary>
public double MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in MeganewtonsPerMeter.
/// </summary>
public double MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter);
/// <summary>
/// Get ForcePerLength in MeganewtonsPerMillimeter.
/// </summary>
public double MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in MicronewtonsPerCentimeter.
/// </summary>
public double MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in MicronewtonsPerMeter.
/// </summary>
public double MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter);
/// <summary>
/// Get ForcePerLength in MicronewtonsPerMillimeter.
/// </summary>
public double MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in MillinewtonsPerCentimeter.
/// </summary>
public double MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in MillinewtonsPerMeter.
/// </summary>
public double MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter);
/// <summary>
/// Get ForcePerLength in MillinewtonsPerMillimeter.
/// </summary>
public double MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in NanonewtonsPerCentimeter.
/// </summary>
public double NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in NanonewtonsPerMeter.
/// </summary>
public double NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter);
/// <summary>
/// Get ForcePerLength in NanonewtonsPerMillimeter.
/// </summary>
public double NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in NewtonsPerCentimeter.
/// </summary>
public double NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter);
/// <summary>
/// Get ForcePerLength in NewtonsPerMeter.
/// </summary>
public double NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter);
/// <summary>
/// Get ForcePerLength in NewtonsPerMillimeter.
/// </summary>
public double NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter);
/// <summary>
/// Get ForcePerLength in PoundsForcePerFoot.
/// </summary>
public double PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot);
/// <summary>
/// Get ForcePerLength in PoundsForcePerInch.
/// </summary>
public double PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch);
/// <summary>
/// Get ForcePerLength in PoundsForcePerYard.
/// </summary>
public double PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard);
/// <summary>
/// Get ForcePerLength in TonnesForcePerCentimeter.
/// </summary>
public double TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter);
/// <summary>
/// Get ForcePerLength in TonnesForcePerMeter.
/// </summary>
public double TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter);
/// <summary>
/// Get ForcePerLength in TonnesForcePerMillimeter.
/// </summary>
public double TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter);
#endregion
#region Static Methods
/// <summary>
/// Get unit abbreviation string.
/// </summary>
/// <param name="unit">Unit to get abbreviation for.</param>
/// <returns>Unit abbreviation string.</returns>
public static string GetAbbreviation(ForcePerLengthUnit unit)
{
return GetAbbreviation(unit, null);
}
/// <summary>
/// Get unit abbreviation string.
/// </summary>
/// <param name="unit">Unit to get abbreviation for.</param>
/// <returns>Unit abbreviation string.</returns>
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
public static string GetAbbreviation(ForcePerLengthUnit unit, [CanBeNull] string cultureName)
{
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
#endregion
#region Static Factory Methods
/// <summary>
/// Get ForcePerLength from CentinewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromCentinewtonsPerCentimeter(double centinewtonspercentimeter)
{
double value = (double) centinewtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from CentinewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromCentinewtonsPerMeter(double centinewtonspermeter)
{
double value = (double) centinewtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from CentinewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromCentinewtonsPerMillimeter(double centinewtonspermillimeter)
{
double value = (double) centinewtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from DecanewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromDecanewtonsPerCentimeter(double decanewtonspercentimeter)
{
double value = (double) decanewtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from DecanewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromDecanewtonsPerMeter(double decanewtonspermeter)
{
double value = (double) decanewtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from DecanewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromDecanewtonsPerMillimeter(double decanewtonspermillimeter)
{
double value = (double) decanewtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from DecinewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromDecinewtonsPerCentimeter(double decinewtonspercentimeter)
{
double value = (double) decinewtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from DecinewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromDecinewtonsPerMeter(double decinewtonspermeter)
{
double value = (double) decinewtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from DecinewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromDecinewtonsPerMillimeter(double decinewtonspermillimeter)
{
double value = (double) decinewtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from KilogramsForcePerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromKilogramsForcePerCentimeter(double kilogramsforcepercentimeter)
{
double value = (double) kilogramsforcepercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerCentimeter);
}
/// <summary>
/// Get ForcePerLength from KilogramsForcePerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromKilogramsForcePerMeter(double kilogramsforcepermeter)
{
double value = (double) kilogramsforcepermeter;
return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMeter);
}
/// <summary>
/// Get ForcePerLength from KilogramsForcePerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromKilogramsForcePerMillimeter(double kilogramsforcepermillimeter)
{
double value = (double) kilogramsforcepermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMillimeter);
}
/// <summary>
/// Get ForcePerLength from KilonewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromKilonewtonsPerCentimeter(double kilonewtonspercentimeter)
{
double value = (double) kilonewtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from KilonewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromKilonewtonsPerMeter(double kilonewtonspermeter)
{
double value = (double) kilonewtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from KilonewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromKilonewtonsPerMillimeter(double kilonewtonspermillimeter)
{
double value = (double) kilonewtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from KilopoundsForcePerFoot.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromKilopoundsForcePerFoot(double kilopoundsforceperfoot)
{
double value = (double) kilopoundsforceperfoot;
return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerFoot);
}
/// <summary>
/// Get ForcePerLength from KilopoundsForcePerInch.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromKilopoundsForcePerInch(double kilopoundsforceperinch)
{
double value = (double) kilopoundsforceperinch;
return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerInch);
}
/// <summary>
/// Get ForcePerLength from MeganewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMeganewtonsPerCentimeter(double meganewtonspercentimeter)
{
double value = (double) meganewtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from MeganewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMeganewtonsPerMeter(double meganewtonspermeter)
{
double value = (double) meganewtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from MeganewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMeganewtonsPerMillimeter(double meganewtonspermillimeter)
{
double value = (double) meganewtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from MicronewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMicronewtonsPerCentimeter(double micronewtonspercentimeter)
{
double value = (double) micronewtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from MicronewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMicronewtonsPerMeter(double micronewtonspermeter)
{
double value = (double) micronewtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from MicronewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMicronewtonsPerMillimeter(double micronewtonspermillimeter)
{
double value = (double) micronewtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from MillinewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMillinewtonsPerCentimeter(double millinewtonspercentimeter)
{
double value = (double) millinewtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from MillinewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMillinewtonsPerMeter(double millinewtonspermeter)
{
double value = (double) millinewtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from MillinewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromMillinewtonsPerMillimeter(double millinewtonspermillimeter)
{
double value = (double) millinewtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from NanonewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromNanonewtonsPerCentimeter(double nanonewtonspercentimeter)
{
double value = (double) nanonewtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from NanonewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromNanonewtonsPerMeter(double nanonewtonspermeter)
{
double value = (double) nanonewtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from NanonewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromNanonewtonsPerMillimeter(double nanonewtonspermillimeter)
{
double value = (double) nanonewtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from NewtonsPerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromNewtonsPerCentimeter(double newtonspercentimeter)
{
double value = (double) newtonspercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerCentimeter);
}
/// <summary>
/// Get ForcePerLength from NewtonsPerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromNewtonsPerMeter(double newtonspermeter)
{
double value = (double) newtonspermeter;
return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMeter);
}
/// <summary>
/// Get ForcePerLength from NewtonsPerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromNewtonsPerMillimeter(double newtonspermillimeter)
{
double value = (double) newtonspermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMillimeter);
}
/// <summary>
/// Get ForcePerLength from PoundsForcePerFoot.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromPoundsForcePerFoot(double poundsforceperfoot)
{
double value = (double) poundsforceperfoot;
return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerFoot);
}
/// <summary>
/// Get ForcePerLength from PoundsForcePerInch.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromPoundsForcePerInch(double poundsforceperinch)
{
double value = (double) poundsforceperinch;
return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerInch);
}
/// <summary>
/// Get ForcePerLength from PoundsForcePerYard.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromPoundsForcePerYard(double poundsforceperyard)
{
double value = (double) poundsforceperyard;
return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerYard);
}
/// <summary>
/// Get ForcePerLength from TonnesForcePerCentimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromTonnesForcePerCentimeter(double tonnesforcepercentimeter)
{
double value = (double) tonnesforcepercentimeter;
return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerCentimeter);
}
/// <summary>
/// Get ForcePerLength from TonnesForcePerMeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromTonnesForcePerMeter(double tonnesforcepermeter)
{
double value = (double) tonnesforcepermeter;
return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMeter);
}
/// <summary>
/// Get ForcePerLength from TonnesForcePerMillimeter.
/// </summary>
/// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
[Windows.Foundation.Metadata.DefaultOverload]
public static ForcePerLength FromTonnesForcePerMillimeter(double tonnesforcepermillimeter)
{
double value = (double) tonnesforcepermillimeter;
return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMillimeter);
}
/// <summary>
/// Dynamically convert from value and unit enum <see cref="ForcePerLengthUnit" /> to <see cref="ForcePerLength" />.
/// </summary>
/// <param name="value">Value to convert from.</param>
/// <param name="fromUnit">Unit to convert from.</param>
/// <returns>ForcePerLength unit value.</returns>
// Fix name conflict with parameter "value"
[return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
public static ForcePerLength From(double value, ForcePerLengthUnit fromUnit)
{
return new ForcePerLength((double)value, fromUnit);
}
#endregion
#region Static Parse Methods
/// <summary>
/// Parse a string with one or two quantities of the format "<quantity> <unit>".
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
/// <example>
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
/// </example>
/// <exception cref="ArgumentNullException">The value of 'str' cannot be null. </exception>
/// <exception cref="ArgumentException">
/// Expected string to have one or two pairs of quantity and unit in the format
/// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in"
/// </exception>
/// <exception cref="AmbiguousUnitParseException">
/// More than one unit is represented by the specified unit abbreviation.
/// Example: Volume.Parse("1 cup") will throw, because it can refer to any of
/// <see cref="VolumeUnit.MetricCup" />, <see cref="VolumeUnit.UsLegalCup" /> and <see cref="VolumeUnit.UsCustomaryCup" />.
/// </exception>
/// <exception cref="UnitsNetException">
/// If anything else goes wrong, typically due to a bug or unhandled case.
/// We wrap exceptions in <see cref="UnitsNetException" /> to allow you to distinguish
/// Units.NET exceptions from other exceptions.
/// </exception>
public static ForcePerLength Parse(string str)
{
return Parse(str, null);
}
/// <summary>
/// Parse a string with one or two quantities of the format "<quantity> <unit>".
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
/// <example>
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
/// </example>
/// <exception cref="ArgumentNullException">The value of 'str' cannot be null. </exception>
/// <exception cref="ArgumentException">
/// Expected string to have one or two pairs of quantity and unit in the format
/// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in"
/// </exception>
/// <exception cref="AmbiguousUnitParseException">
/// More than one unit is represented by the specified unit abbreviation.
/// Example: Volume.Parse("1 cup") will throw, because it can refer to any of
/// <see cref="VolumeUnit.MetricCup" />, <see cref="VolumeUnit.UsLegalCup" /> and <see cref="VolumeUnit.UsCustomaryCup" />.
/// </exception>
/// <exception cref="UnitsNetException">
/// If anything else goes wrong, typically due to a bug or unhandled case.
/// We wrap exceptions in <see cref="UnitsNetException" /> to allow you to distinguish
/// Units.NET exceptions from other exceptions.
/// </exception>
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
public static ForcePerLength Parse(string str, [CanBeNull] string cultureName)
{
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
return QuantityParser.Default.Parse<ForcePerLength, ForcePerLengthUnit>(
str,
provider,
From);
}
/// <summary>
/// Try to parse a string with one or two quantities of the format "<quantity> <unit>".
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
/// <param name="result">Resulting unit quantity if successful.</param>
/// <example>
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
/// </example>
public static bool TryParse([CanBeNull] string str, out ForcePerLength result)
{
return TryParse(str, null, out result);
}
/// <summary>
/// Try to parse a string with one or two quantities of the format "<quantity> <unit>".
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
/// <param name="result">Resulting unit quantity if successful.</param>
/// <returns>True if successful, otherwise false.</returns>
/// <example>
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
/// </example>
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ForcePerLength result)
{
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
return QuantityParser.Default.TryParse<ForcePerLength, ForcePerLengthUnit>(
str,
provider,
From,
out result);
}
/// <summary>
/// Parse a unit string.
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
/// <example>
/// Length.ParseUnit("m", new CultureInfo("en-US"));
/// </example>
/// <exception cref="ArgumentNullException">The value of 'str' cannot be null. </exception>
/// <exception cref="UnitsNetException">Error parsing string.</exception>
public static ForcePerLengthUnit ParseUnit(string str)
{
return ParseUnit(str, null);
}
/// <summary>
/// Parse a unit string.
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
/// <example>
/// Length.ParseUnit("m", new CultureInfo("en-US"));
/// </example>
/// <exception cref="ArgumentNullException">The value of 'str' cannot be null. </exception>
/// <exception cref="UnitsNetException">Error parsing string.</exception>
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
public static ForcePerLengthUnit ParseUnit(string str, [CanBeNull] string cultureName)
{
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
return UnitParser.Default.Parse<ForcePerLengthUnit>(str, provider);
}
public static bool TryParseUnit(string str, out ForcePerLengthUnit unit)
{
return TryParseUnit(str, null, out unit);
}
/// <summary>
/// Parse a unit string.
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
/// <param name="unit">The parsed unit if successful.</param>
/// <returns>True if successful, otherwise false.</returns>
/// <example>
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
/// </example>
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ForcePerLengthUnit unit)
{
IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);
return UnitParser.Default.TryParse<ForcePerLengthUnit>(str, provider, out unit);
}
#endregion
#region Equality / IComparable
public int CompareTo(object obj)
{
if(obj is null) throw new ArgumentNullException(nameof(obj));
if(!(obj is ForcePerLength objForcePerLength)) throw new ArgumentException("Expected type ForcePerLength.", nameof(obj));
return CompareTo(objForcePerLength);
}
// Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods
internal int CompareTo(ForcePerLength other)
{
return _value.CompareTo(other.AsBaseNumericType(this.Unit));
}
[Windows.Foundation.Metadata.DefaultOverload]
public override bool Equals(object obj)
{
if(obj is null || !(obj is ForcePerLength objForcePerLength))
return false;
return Equals(objForcePerLength);
}
public bool Equals(ForcePerLength other)
{
return _value.Equals(other.AsBaseNumericType(this.Unit));
}
/// <summary>
/// <para>
/// Compare equality to another ForcePerLength within the given absolute or relative tolerance.
/// </para>
/// <para>
/// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
/// <paramref name="other"/> as a percentage of this quantity's value. <paramref name="other"/> will be converted into
/// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
/// this quantity's value to be considered equal.
/// <example>
/// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
/// <code>
/// var a = Length.FromMeters(2.0);
/// var b = Length.FromInches(50.0);
/// a.Equals(b, 0.01, ComparisonType.Relative);
/// </code>
/// </example>
/// </para>
/// <para>
/// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
/// <paramref name="other"/> as a fixed number in this quantity's unit. <paramref name="other"/> will be converted into
/// this quantity's unit for comparison.
/// <example>
/// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
/// <code>
/// var a = Length.FromMeters(2.0);
/// var b = Length.FromInches(50.0);
/// a.Equals(b, 0.01, ComparisonType.Absolute);
/// </code>
/// </example>
/// </para>
/// <para>
/// Note that it is advised against specifying zero difference, due to the nature
/// of floating point operations and using System.Double internally.
/// </para>
/// </summary>
/// <param name="other">The other quantity to compare to.</param>
/// <param name="tolerance">The absolute or relative tolerance value. Must be greater than or equal to 0.</param>
/// <param name="comparisonType">The comparison type: either relative or absolute.</param>
/// <returns>True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.</returns>
public bool Equals(ForcePerLength other, double tolerance, ComparisonType comparisonType)
{
if(tolerance < 0)
throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
double thisValue = (double)this.Value;
double otherValueInThisUnits = other.As(this.Unit);
return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
}