Click or drag to resize

Quantity Class

Мeasure-safe immutable quantity with measurement unit. Allows measurement unit safe calculations.
Inheritance Hierarchy
SystemObject
  Aloe.EnterpriseOne.ModelQuantity

Namespace:  Aloe.EnterpriseOne.Model
Assembly:  Aloe.EnterpriseOne.Model (in Aloe.EnterpriseOne.Model.dll) Version: 20.1.3.5
Syntax
public class Quantity : IComparable, IComparable<Quantity>, 
	IEquatable<Quantity>, IValueWithMeasure<MeasurementUnit>

The Quantity type exposes the following members.

Constructors
  NameDescription
Public methodQuantity
Initializes a new instance of the Quantity class.
Top
Properties
  NameDescription
Public propertyUnit
Gets the measurement unit of the quantity.
Public propertyValue
Gets the value of the quantity.
Top
Methods
  NameDescription
Public methodStatic memberAdd
Returns the sum of the specified quantities. The quantities must have the same Unit.
Public methodStatic memberAreCompatible
Returns true if the two quantities are compatible (e.g. have the same unit).
Public methodStatic memberCompare
Compares the quantities. The quantities must have the same unit.
Public methodCompareTo(Object)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Public methodCompareTo(Quantity)
Compares the current object with another object of the same type.
Public methodStatic memberDivide
Divides the specified quantities. The operation is successful only if both quantities have the same measurement unit.
Public methodEquals(Object)
Determines whether the specified Object, is equal to this instance.
(Overrides ObjectEquals(Object).)
Public methodEquals(Quantity)
Indicates whether the current object is equal to another object of the same type.
Public methodGetHashCode
Returns a hash code for this instance.
(Overrides ObjectGetHashCode.)
Public methodStatic memberMultiply
Multiplies the specified quantity with the specified multiplier.
Public methodStatic memberSubtract
Subtracts the second quantity from the first. The quantities must have the same Unit.
Public methodToString
Returns a String that represents this instance.
(Overrides ObjectToString.)
Public methodToString(CultureInfo)
Returns a String that represents this instance.
Top
Operators
  NameDescription
Public operatorStatic memberAddition
Returns the sum of quantity a and b, which must have the same measurement unit
Public operatorStatic memberDivision
Implements the operator /.
Public operatorStatic memberEquality
Implements the operator ==.
Public operatorStatic memberGreaterThan
Compares first and second.
Public operatorStatic memberGreaterThanOrEqual
Implements the operator >=.
Public operatorStatic memberInequality
Implements the operator !=.
Public operatorStatic memberLessThan
Implements the operator <.
Public operatorStatic memberLessThanOrEqual
Implements the operator <=.
Public operatorStatic memberMultiply(Decimal, Quantity)
Implements the operator *.
Public operatorStatic memberMultiply(Quantity, Decimal)
Implements the operator *.
Public operatorStatic memberSubtraction
Subtracts the second quantity from the first. The quantities must have the same Unit.
Top
Extension Methods
  NameDescription
Public Extension MethodRound
Rounds the quantity as per the precision, supported by the system (0.001).
(Defined by QuantityExtensions.)
Top
Remarks

Quantity supports basic quantity arithmetic, which is measure-safe. For example, adding two quantities is measure-safe, because the two quantities are added successfully only if their measurement units are compatible. This helps avoid errors of inadvertently doing quantity arithmetic with incompatible measurement units.

The following basic rules are true for Quantity:

  • Quantity(15, Pcs) + Quantity(10, Pcs) == Quantity(25, Pcs)
  • Quantity(15, Pcs) + Quantity(10, Kg) => Exception!
  • Quantity(15, Pcs) + Quantity(10, null) => Exception!
  • Quantity(15, Pcs) + Quantity(0, null) == Quantity(15, Pcs)
  • Quantity(15, Pcs) + Quantity(0, Kg) == Quantity(15, Pcs)
  • Quantity(15, Pcs) + null == Quantity(15, Pcs)
  • Quantity(15, Pcs) * 3 == Quantity(45, Pcs)
  • Quantity(15, Pcs) > Quantity(10, Pcs) == true
  • Quantity(15, Pcs) > Quantity(0, Kg) == true
  • Quantity(15, Pcs) > Quantity(10, Kg) => Exception!
  • Quantity(15, Pcs) > null == true

See Also