1
+ // Copyright © 2007 by Initial Force AS. All rights reserved.
2
+ // https://github.com/InitialForce/UnitsNet
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ // of this software and associated documentation files (the "Software"), to deal
6
+ // in the Software without restriction, including without limitation the rights
7
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ // copies of the Software, and to permit persons to whom the Software is
9
+ // furnished to do so, subject to the following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included in
12
+ // all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ // THE SOFTWARE.
21
+
22
+ using System ;
23
+
24
+ namespace UnitsNet
25
+ {
26
+ [ AttributeUsage ( AttributeTargets . Field ) ]
27
+ public class LengthAttribute : UnitAttribute
28
+ {
29
+ public LengthAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
30
+ {
31
+ }
32
+ }
33
+
34
+ [ AttributeUsage ( AttributeTargets . Field ) ]
35
+ public class MassAttribute : UnitAttribute
36
+ {
37
+ public MassAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
38
+ {
39
+ }
40
+ }
41
+
42
+ [ AttributeUsage ( AttributeTargets . Field ) ]
43
+ public class AngleAttribute : UnitAttribute
44
+ {
45
+ public AngleAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
46
+ {
47
+ }
48
+ }
49
+
50
+ [ AttributeUsage ( AttributeTargets . Field ) ]
51
+ public class AreaAttribute : UnitAttribute
52
+ {
53
+ public AreaAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
54
+ {
55
+ }
56
+ }
57
+
58
+ [ AttributeUsage ( AttributeTargets . Field ) ]
59
+ public class ElectricPotentialAttribute : UnitAttribute
60
+ {
61
+ public ElectricPotentialAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
62
+ {
63
+ }
64
+ }
65
+
66
+ [ AttributeUsage ( AttributeTargets . Field ) ]
67
+ public class FlowAttribute : UnitAttribute
68
+ {
69
+ public FlowAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
70
+ {
71
+ }
72
+ }
73
+
74
+ [ AttributeUsage ( AttributeTargets . Field ) ]
75
+ public class ForceAttribute : UnitAttribute
76
+ {
77
+ public ForceAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
78
+ {
79
+ }
80
+ }
81
+
82
+ [ AttributeUsage ( AttributeTargets . Field ) ]
83
+ public class PressureAttribute : UnitAttribute
84
+ {
85
+ public PressureAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
86
+ {
87
+ }
88
+ }
89
+
90
+ [ AttributeUsage ( AttributeTargets . Field ) ]
91
+ public class RotationalSpeedAttribute : UnitAttribute
92
+ {
93
+ public RotationalSpeedAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
94
+ {
95
+ }
96
+ }
97
+
98
+ [ AttributeUsage ( AttributeTargets . Field ) ]
99
+ public class TorqueAttribute : UnitAttribute
100
+ {
101
+ public TorqueAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
102
+ {
103
+ }
104
+ }
105
+
106
+ [ AttributeUsage ( AttributeTargets . Field ) ]
107
+ public class VolumeAttribute : UnitAttribute
108
+ {
109
+ public VolumeAttribute ( double ratio , string pluralName = null ) : base ( pluralName , ratio )
110
+ {
111
+ }
112
+ }
113
+
114
+ [ AttributeUsage ( AttributeTargets . Field ) ]
115
+ public class UnitAttribute : Attribute
116
+ {
117
+ /// <summary>
118
+ /// Ratio of unit to base unit. For example, <see cref="Unit.Kilometer"/> is 1000:1 of the base unit <see cref="Unit.Meter"/>.
119
+ /// </summary>
120
+ public readonly double Ratio ;
121
+
122
+ /// <summary>
123
+ /// Name of unit in plural form. Will be used as property name such as Force.FromNewtonmeters().
124
+ /// </summary>
125
+ public readonly string PluralName ;
126
+
127
+ ///// <summary>
128
+ ///// Name of unit in singular form. Will be used as ???.
129
+ ///// </summary>
130
+ //public string SingularName { get; set; }
131
+
132
+ public UnitAttribute ( string pluralName , double ratio )
133
+ {
134
+ Ratio = ratio ;
135
+ PluralName = pluralName ;
136
+ //SingularName = null;
137
+ }
138
+ }
139
+ }
0 commit comments