@@ -30,8 +30,9 @@ public static TQuantity Abs<TQuantity>(this TQuantity value) where TQuantity : I
30
30
/// <exception cref="ArgumentException">
31
31
/// <paramref name="source">source</paramref> contains quantity types different from <paramref name="unitType" />.
32
32
/// </exception>
33
- public static TQuantity Sum < TQuantity > ( this IEnumerable < TQuantity > source , Enum unitType )
34
- where TQuantity : IQuantity
33
+ public static TQuantity Sum < TQuantity , TUnitType > ( this IEnumerable < TQuantity > source , TUnitType unitType )
34
+ where TUnitType : Enum
35
+ where TQuantity : IQuantity < TUnitType >
35
36
{
36
37
return ( TQuantity ) Quantity . From ( source . Sum ( x => x . As ( unitType ) ) , unitType ) ;
37
38
}
@@ -44,16 +45,18 @@ public static TQuantity Sum<TQuantity>(this IEnumerable<TQuantity> source, Enum
44
45
/// <param name="selector">A transform function to apply to each element.</param>
45
46
/// <param name="unitType">The desired unit type for the resulting quantity</param>
46
47
/// <typeparam name="TSource">The type of the elements of source.</typeparam>
47
- /// <typeparam name="TQuantity">The type of quantity that is produced by this operation</typeparam>
48
+ /// <typeparam name="TQuantity">The type of quantity that is produced by this operation.</typeparam>
49
+ /// <typeparam name="TUnitType">The type of unit enum.</typeparam>
48
50
/// <returns>The sum of the projected values, represented in the specified unit type.</returns>
49
51
/// <exception cref="T:System.ArgumentNullException">
50
52
/// <paramref name="source">source</paramref> or <paramref name="selector">selector</paramref> is null.
51
53
/// </exception>
52
54
/// <exception cref="ArgumentException">
53
55
/// <paramref name="source">source</paramref> contains quantity types different from <paramref name="unitType" />.
54
56
/// </exception>
55
- public static TQuantity Sum < TSource , TQuantity > ( this IEnumerable < TSource > source , Func < TSource , TQuantity > selector , Enum unitType )
56
- where TQuantity : IQuantity
57
+ public static TQuantity Sum < TSource , TQuantity , TUnitType > ( this IEnumerable < TSource > source , Func < TSource , TQuantity > selector , TUnitType unitType )
58
+ where TUnitType : Enum
59
+ where TQuantity : IQuantity < TUnitType >
57
60
{
58
61
return source . Select ( selector ) . Sum ( unitType ) ;
59
62
}
@@ -79,8 +82,9 @@ public static TQuantity Min<TQuantity>(TQuantity val1, TQuantity val2) where TQu
79
82
/// <exception cref="ArgumentException">
80
83
/// <paramref name="source">source</paramref> contains quantity types different from <paramref name="unitType" />.
81
84
/// </exception>
82
- public static TQuantity Min < TQuantity > ( this IEnumerable < TQuantity > source , Enum unitType )
83
- where TQuantity : IQuantity
85
+ public static TQuantity Min < TQuantity , TUnitType > ( this IEnumerable < TQuantity > source , TUnitType unitType )
86
+ where TUnitType : Enum
87
+ where TQuantity : IQuantity < TUnitType >
84
88
{
85
89
return ( TQuantity ) Quantity . From ( source . Min ( x => x . As ( unitType ) ) , unitType ) ;
86
90
}
@@ -93,7 +97,8 @@ public static TQuantity Min<TQuantity>(this IEnumerable<TQuantity> source, Enum
93
97
/// <param name="selector">A transform function to apply to each element.</param>
94
98
/// <param name="unitType">The desired unit type for the resulting quantity</param>
95
99
/// <typeparam name="TSource">The type of the elements of source.</typeparam>
96
- /// <typeparam name="TQuantity">The type of quantity that is produced by this operation</typeparam>
100
+ /// <typeparam name="TQuantity">The type of quantity that is produced by this operation.</typeparam>
101
+ /// <typeparam name="TUnitType">The type of unit enum.</typeparam>
97
102
/// <returns>The min of the projected values, represented in the specified unit type.</returns>
98
103
/// <exception cref="T:System.ArgumentNullException">
99
104
/// <paramref name="source">source</paramref> or <paramref name="selector">selector</paramref> is null.
@@ -102,8 +107,9 @@ public static TQuantity Min<TQuantity>(this IEnumerable<TQuantity> source, Enum
102
107
/// <exception cref="ArgumentException">
103
108
/// <paramref name="source">source</paramref> contains quantity types different from <paramref name="unitType" />.
104
109
/// </exception>
105
- public static TQuantity Min < TSource , TQuantity > ( this IEnumerable < TSource > source , Func < TSource , TQuantity > selector , Enum unitType )
106
- where TQuantity : IQuantity
110
+ public static TQuantity Min < TSource , TQuantity , TUnitType > ( this IEnumerable < TSource > source , Func < TSource , TQuantity > selector , TUnitType unitType )
111
+ where TUnitType : Enum
112
+ where TQuantity : IQuantity < TUnitType >
107
113
{
108
114
return source . Select ( selector ) . Min ( unitType ) ;
109
115
}
@@ -129,8 +135,9 @@ public static TQuantity Max<TQuantity>(TQuantity val1, TQuantity val2) where TQu
129
135
/// <exception cref="ArgumentException">
130
136
/// <paramref name="source">source</paramref> contains quantity types different from <paramref name="unitType" />.
131
137
/// </exception>
132
- public static TQuantity Max < TQuantity > ( this IEnumerable < TQuantity > source , Enum unitType )
133
- where TQuantity : IQuantity
138
+ public static TQuantity Max < TQuantity , TUnitType > ( this IEnumerable < TQuantity > source , TUnitType unitType )
139
+ where TUnitType : Enum
140
+ where TQuantity : IQuantity < TUnitType >
134
141
{
135
142
return ( TQuantity ) Quantity . From ( source . Max ( x => x . As ( unitType ) ) , unitType ) ;
136
143
}
@@ -143,7 +150,8 @@ public static TQuantity Max<TQuantity>(this IEnumerable<TQuantity> source, Enum
143
150
/// <param name="selector">A transform function to apply to each element.</param>
144
151
/// <param name="unitType">The desired unit type for the resulting quantity</param>
145
152
/// <typeparam name="TSource">The type of the elements of source.</typeparam>
146
- /// <typeparam name="TQuantity">The type of quantity that is produced by this operation</typeparam>
153
+ /// <typeparam name="TQuantity">The type of quantity that is produced by this operation.</typeparam>
154
+ /// <typeparam name="TUnitType">The type of unit enum.</typeparam>
147
155
/// <returns>The max of the projected values, represented in the specified unit type.</returns>
148
156
/// <exception cref="T:System.ArgumentNullException">
149
157
/// <paramref name="source">source</paramref> or <paramref name="selector">selector</paramref> is null.
@@ -152,8 +160,9 @@ public static TQuantity Max<TQuantity>(this IEnumerable<TQuantity> source, Enum
152
160
/// <exception cref="ArgumentException">
153
161
/// <paramref name="source">source</paramref> contains quantity types different from <paramref name="unitType" />.
154
162
/// </exception>
155
- public static TQuantity Max < TSource , TQuantity > ( this IEnumerable < TSource > source , Func < TSource , TQuantity > selector , Enum unitType )
156
- where TQuantity : IQuantity
163
+ public static TQuantity Max < TSource , TQuantity , TUnitType > ( this IEnumerable < TSource > source , Func < TSource , TQuantity > selector , TUnitType unitType )
164
+ where TUnitType : Enum
165
+ where TQuantity : IQuantity < TUnitType >
157
166
{
158
167
return source . Select ( selector ) . Max ( unitType ) ;
159
168
}
@@ -169,8 +178,9 @@ public static TQuantity Max<TSource, TQuantity>(this IEnumerable<TSource> source
169
178
/// <exception cref="ArgumentException">
170
179
/// <paramref name="source">source</paramref> contains quantity types different from <paramref name="unitType" />.
171
180
/// </exception>
172
- public static TQuantity Average < TQuantity > ( this IEnumerable < TQuantity > source , Enum unitType )
173
- where TQuantity : IQuantity
181
+ public static TQuantity Average < TQuantity , TUnitType > ( this IEnumerable < TQuantity > source , TUnitType unitType )
182
+ where TUnitType : Enum
183
+ where TQuantity : IQuantity < TUnitType >
174
184
{
175
185
return ( TQuantity ) Quantity . From ( source . Average ( x => x . As ( unitType ) ) , unitType ) ;
176
186
}
@@ -183,7 +193,8 @@ public static TQuantity Average<TQuantity>(this IEnumerable<TQuantity> source, E
183
193
/// <param name="selector">A transform function to apply to each element.</param>
184
194
/// <param name="unitType">The desired unit type for the resulting quantity</param>
185
195
/// <typeparam name="TSource">The type of the elements of source.</typeparam>
186
- /// <typeparam name="TQuantity">The type of quantity that is produced by this operation</typeparam>
196
+ /// <typeparam name="TQuantity">The type of quantity that is produced by this operation.</typeparam>
197
+ /// <typeparam name="TUnitType">The type of unit enum.</typeparam>
187
198
/// <returns>The average of the projected values, represented in the specified unit type.</returns>
188
199
/// <exception cref="T:System.ArgumentNullException">
189
200
/// <paramref name="source">source</paramref> or <paramref name="selector">selector</paramref> is null.
@@ -192,8 +203,9 @@ public static TQuantity Average<TQuantity>(this IEnumerable<TQuantity> source, E
192
203
/// <exception cref="ArgumentException">
193
204
/// <paramref name="source">source</paramref> contains quantity types different from <paramref name="unitType" />.
194
205
/// </exception>
195
- public static TQuantity Average < TSource , TQuantity > ( this IEnumerable < TSource > source , Func < TSource , TQuantity > selector , Enum unitType )
196
- where TQuantity : IQuantity
206
+ public static TQuantity Average < TSource , TQuantity , TUnitType > ( this IEnumerable < TSource > source , Func < TSource , TQuantity > selector , TUnitType unitType )
207
+ where TUnitType : Enum
208
+ where TQuantity : IQuantity < TUnitType >
197
209
{
198
210
return source . Select ( selector ) . Average ( unitType ) ;
199
211
}
0 commit comments