@@ -183,7 +183,7 @@ private void GenerateInstanceConstructors()
183183 /// <exception cref=""ArgumentException"">If value is NaN or Infinity.</exception>
184184 public { _quantity . Name } ({ _quantity . BaseType } value, { _unitEnumName } unit)
185185 {{
186- if(unit == { _unitEnumName } .Undefined)
186+ if (unit == { _unitEnumName } .Undefined)
187187 throw new ArgumentException(""The quantity can not be created with an undefined unit."", nameof(unit));
188188" ) ;
189189
@@ -206,7 +206,7 @@ private void GenerateInstanceConstructors()
206206 /// <exception cref=""ArgumentException"">No unit was found for the given <see cref=""UnitSystem""/>.</exception>
207207 public { _quantity . Name } ({ _valueType } value, UnitSystem unitSystem)
208208 {{
209- if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
209+ if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
210210
211211 var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
212212 var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -334,7 +334,7 @@ private void GenerateConversionProperties()
334334" ) ;
335335 foreach ( var unit in _quantity . Units )
336336 {
337- if ( unit . SkipConversionGeneration )
337+ if ( unit . SkipConversionGeneration )
338338 continue ;
339339
340340 Writer . WL ( $@ "
@@ -369,7 +369,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter)
369369
370370 foreach ( var unit in _quantity . Units )
371371 {
372- if ( unit . SingularName == _quantity . BaseUnit )
372+ if ( unit . SingularName == _quantity . BaseUnit )
373373 continue ;
374374
375375 var func = unit . FromBaseToUnitFunc . Replace ( "{x}" , "quantity.Value" ) ;
@@ -378,15 +378,15 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter)
378378 }
379379
380380 Writer . WL ( $@ "
381-
381+
382382 // Register in unit converter: BaseUnit <-> BaseUnit
383383 unitConverter.SetConversionFunction<{ _quantity . Name } >({ _unitEnumName } .{ _quantity . BaseUnit } , { _unitEnumName } .{ _quantity . BaseUnit } , quantity => quantity);
384384
385385 // Register in unit converter: { _quantity . Name } Unit -> BaseUnit" ) ;
386386
387387 foreach ( var unit in _quantity . Units )
388388 {
389- if ( unit . SingularName == _quantity . BaseUnit )
389+ if ( unit . SingularName == _quantity . BaseUnit )
390390 continue ;
391391
392392 var func = unit . FromUnitToBaseFunc . Replace ( "{x}" , "quantity.Value" ) ;
@@ -448,7 +448,7 @@ private void GenerateStaticFactoryMethods()
448448" ) ;
449449 foreach ( var unit in _quantity . Units )
450450 {
451- if ( unit . SkipConversionGeneration )
451+ if ( unit . SkipConversionGeneration )
452452 continue;
453453
454454 var valueParamName = unit. PluralName . ToLowerInvariant ( ) ;
@@ -801,8 +801,8 @@ private void GenerateEqualityAndComparison()
801801 /// <inheritdoc />
802802 public int CompareTo(object obj)
803803 {{
804- if(obj is null) throw new ArgumentNullException(nameof(obj));
805- if(!(obj is { _quantity . Name } obj{ _quantity . Name } )) throw new ArgumentException(""Expected type { _quantity . Name } ."", nameof(obj));
804+ if (obj is null) throw new ArgumentNullException(nameof(obj));
805+ if (!(obj is { _quantity . Name } obj{ _quantity . Name } )) throw new ArgumentException(""Expected type { _quantity . Name } ."", nameof(obj));
806806
807807 return CompareTo(obj{ _quantity . Name } );
808808 }}
@@ -817,7 +817,7 @@ public int CompareTo({_quantity.Name} other)
817817 /// <remarks>Consider using <see cref=""Equals({ _quantity . Name } , double, ComparisonType)""/> for safely comparing floating point values.</remarks>
818818 public override bool Equals(object obj)
819819 {{
820- if(obj is null || !(obj is { _quantity . Name } obj{ _quantity . Name } ))
820+ if (obj is null || !(obj is { _quantity . Name } obj{ _quantity . Name } ))
821821 return false;
822822
823823 return Equals(obj{ _quantity . Name } );
@@ -872,7 +872,7 @@ public bool Equals({_quantity.Name} other)
872872 /// <returns>True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.</returns>
873873 public bool Equals({ _quantity . Name } other, double tolerance, ComparisonType comparisonType)
874874 {{
875- if(tolerance < 0)
875+ if (tolerance < 0)
876876 throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0."");
877877
878878 double thisValue = (double)this.Value;
@@ -905,7 +905,7 @@ private void GenerateConversionMethods()
905905 /// <returns>Value converted to the specified unit.</returns>
906906 public double As({ _unitEnumName } unit)
907907 {{
908- if(Unit == unit)
908+ if (Unit == unit)
909909 return Convert.ToDouble(Value);
910910
911911 var converted = GetValueAs(unit);
@@ -915,13 +915,13 @@ public double As({_unitEnumName} unit)
915915 /// <inheritdoc cref=""IQuantity.As(UnitSystem)""/>
916916 public double As(UnitSystem unitSystem)
917917 {{
918- if(unitSystem is null)
918+ if (unitSystem is null)
919919 throw new ArgumentNullException(nameof(unitSystem));
920920
921921 var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
922922
923923 var firstUnitInfo = unitInfos.FirstOrDefault();
924- if(firstUnitInfo == null)
924+ if (firstUnitInfo == null)
925925 throw new ArgumentException(""No units were found for the given UnitSystem."", nameof(unitSystem));
926926
927927 return As(firstUnitInfo.Value);
@@ -930,7 +930,7 @@ public double As(UnitSystem unitSystem)
930930 /// <inheritdoc />
931931 double IQuantity.As(Enum unit)
932932 {{
933- if(!(unit is { _unitEnumName } unitAs{ _unitEnumName } ))
933+ if (!(unit is { _unitEnumName } unitAs{ _unitEnumName } ))
934934 throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({ _unitEnumName } )}} is supported."", nameof(unit));
935935
936936 return As(unitAs{ _unitEnumName } );
@@ -954,18 +954,18 @@ double IQuantity.As(Enum unit)
954954 /// <returns>A { _quantity . Name } with the specified unit.</returns>
955955 public { _quantity . Name } ToUnit({ _unitEnumName } unit, UnitConverter unitConverter)
956956 {{
957- if(Unit == unit)
957+ if (Unit == unit)
958958 {{
959959 // Already in requested units.
960960 return this;
961961 }}
962- else if(unitConverter.TryGetConversionFunction((typeof({ _quantity . Name } ), Unit, typeof({ _quantity . Name } ), unit), out var conversionFunction))
962+ else if (unitConverter.TryGetConversionFunction((typeof({ _quantity . Name } ), Unit, typeof({ _quantity . Name } ), unit), out var conversionFunction))
963963 {{
964964 // Direct conversion to requested unit found. Return the converted quantity.
965965 var converted = conversionFunction(this);
966966 return ({ _quantity . Name } )converted;
967967 }}
968- else if(Unit != BaseUnit)
968+ else if (Unit != BaseUnit)
969969 {{
970970 // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit.
971971 var inBaseUnits = ToUnit(BaseUnit);
@@ -980,7 +980,7 @@ double IQuantity.As(Enum unit)
980980 /// <inheritdoc />
981981 IQuantity IQuantity.ToUnit(Enum unit)
982982 {{
983- if(!(unit is { _unitEnumName } unitAs{ _unitEnumName } ))
983+ if (!(unit is { _unitEnumName } unitAs{ _unitEnumName } ))
984984 throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({ _unitEnumName } )}} is supported."", nameof(unit));
985985
986986 return ToUnit(unitAs{ _unitEnumName } , DefaultConversionFunctions);
@@ -989,7 +989,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
989989 /// <inheritdoc />
990990 IQuantity IQuantity.ToUnit(Enum unit, UnitConverter unitConverter)
991991 {{
992- if(!(unit is { _unitEnumName } unitAs{ _unitEnumName } ))
992+ if (!(unit is { _unitEnumName } unitAs{ _unitEnumName } ))
993993 throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({ _unitEnumName } )}} is supported."", nameof(unit));
994994
995995 return ToUnit(unitAs{ _unitEnumName } , unitConverter);
@@ -998,13 +998,13 @@ IQuantity IQuantity.ToUnit(Enum unit, UnitConverter unitConverter)
998998 /// <inheritdoc cref=""IQuantity.ToUnit(UnitSystem)""/>
999999 public { _quantity . Name } ToUnit(UnitSystem unitSystem)
10001000 {{
1001- if(unitSystem is null)
1001+ if (unitSystem is null)
10021002 throw new ArgumentNullException(nameof(unitSystem));
10031003
10041004 var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
10051005
10061006 var firstUnitInfo = unitInfos.FirstOrDefault();
1007- if(firstUnitInfo == null)
1007+ if (firstUnitInfo == null)
10081008 throw new ArgumentException(""No units were found for the given UnitSystem."", nameof(unitSystem));
10091009
10101010 return ToUnit(firstUnitInfo.Value);
@@ -1189,15 +1189,15 @@ string IConvertible.ToString(IFormatProvider provider)
11891189
11901190 object IConvertible.ToType(Type conversionType, IFormatProvider provider)
11911191 {{
1192- if(conversionType == typeof({ _quantity . Name } ))
1192+ if (conversionType == typeof({ _quantity . Name } ))
11931193 return this;
1194- else if(conversionType == typeof({ _unitEnumName } ))
1194+ else if (conversionType == typeof({ _unitEnumName } ))
11951195 return Unit;
1196- else if(conversionType == typeof(QuantityType))
1196+ else if (conversionType == typeof(QuantityType))
11971197 return { _quantity . Name } .QuantityType;
1198- else if(conversionType == typeof(QuantityInfo))
1198+ else if (conversionType == typeof(QuantityInfo))
11991199 return { _quantity . Name } .Info;
1200- else if(conversionType == typeof(BaseDimensions))
1200+ else if (conversionType == typeof(BaseDimensions))
12011201 return { _quantity . Name } .BaseDimensions;
12021202 else
12031203 throw new InvalidCastException($""Converting {{typeof({ _quantity . Name } )}} to {{conversionType}} is not supported."");
0 commit comments