Class Unit
- Namespace
- Codebelt.Unitify
- Assembly
- Codebelt.Unitify.dll
Represents the base class from which all implementations of a unit of measure should derive.
public abstract class Unit : IUnit, IBaseUnit, IEquatable<IUnit>
- Inheritance
-
ObjectUnit
- Implements
-
IEquatable<IUnit>
- Derived
Constructors
Unit(IBaseUnit, Double, Action<UnitFormatOptions>)
Initializes a new instance of the Unit class.
protected Unit(IBaseUnit baseUnit, double value, Action<UnitFormatOptions> setup = null)
Parameters
baseUnit
IBaseUnitThe base unit of measure.
value
DoubleThe value of this unit expressed as bytes.
setup
Action<UnitFormatOptions>The UnitFormatOptions which may be configured.
Properties
Ampere
Gets the SI base unit for Electric Current.
public static IBaseUnit Ampere { get; }
Property Value
- IBaseUnit
The SI base unit for Electric Current.
- See Also
Becquerel
Gets the SI unit for Radioactivity.
public static IBaseUnit Becquerel { get; }
Property Value
- IBaseUnit
The SI unit for Radioactivity.
- See Also
Bit
Gets the base unit for Data Quantity.
public static IBaseUnit Bit { get; }
Property Value
- IBaseUnit
The base unit for Data Quantity.
- See Also
BitPerSecond
Gets the base unit for Transmission Rate.
public static IBaseUnit BitPerSecond { get; }
Property Value
- IBaseUnit
The base unit for Transmission Rate.
- See Also
Byte
Gets the unit for Data Quantity.
public static IBaseUnit Byte { get; }
Property Value
- IBaseUnit
The unit for Data Quantity.
- See Also
Candela
Gets the SI base unit for Luminous Intensity.
public static IBaseUnit Candela { get; }
Property Value
- IBaseUnit
The SI base unit for Luminous Intensity.
- See Also
Category
Gets the category of unit.
public string Category { get; }
Property Value
- String
The category of the unit.
Celsius
Gets the SI unit for Temperature.
public static IBaseUnit Celsius { get; }
Property Value
- IBaseUnit
The SI unit for Temperature.
- See Also
Coulomb
Gets the SI unit for Electric Charge.
public static IBaseUnit Coulomb { get; }
Property Value
- IBaseUnit
The SI unit for Electric Charge.
- See Also
Farad
Gets the SI unit for Electric Capacitance.
public static IBaseUnit Farad { get; }
Property Value
- IBaseUnit
The SI unit for Electric Capacitance.
- See Also
FormatOptions
Gets the format options of the unit.
public UnitFormatOptions FormatOptions { get; protected set; }
Property Value
- UnitFormatOptions
The format options of the unit.
Gram
Gets the opinionated base unit for Mass.
public static IBaseUnit Gram { get; }
Property Value
- IBaseUnit
The opinionated base unit for Mass.
Remarks
For consistency with this library, Kilogram (which is the official SI base unit for Mass) has been replaced with Gram.
- See Also
Gray
Gets the SI unit for Absorbed Dose.
public static IBaseUnit Gray { get; }
Property Value
- IBaseUnit
The SI unit for Absorbed Dose.
- See Also
Henry
Gets the opinionated base unit for Inductance.
public static IBaseUnit Henry { get; }
Property Value
- IBaseUnit
The opinionated base unit for Inductance.
- See Also
Hertz
Gets the SI unit for Frequency.
public static IBaseUnit Hertz { get; }
Property Value
- IBaseUnit
The SI unit for Frequency.
- See Also
Joule
Gets the SI unit for Energy.
public static IBaseUnit Joule { get; }
Property Value
- IBaseUnit
The SI unit for Energy.
- See Also
Katal
Gets the SI unit for Catalytic Activity.
public static IBaseUnit Katal { get; }
Property Value
- IBaseUnit
The SI unit for Catalytic Activity.
- See Also
Kelvin
Gets the SI base unit for Temperature.
public static IBaseUnit Kelvin { get; }
Property Value
- IBaseUnit
The SI base unit for Temperature.
- See Also
Lumen
Gets the SI unit for Luminous Flux.
public static IBaseUnit Lumen { get; }
Property Value
- IBaseUnit
The SI unit for Luminous Flux.
- See Also
Lux
Gets the SI unit for Illuminance.
public static IBaseUnit Lux { get; }
Property Value
- IBaseUnit
The SI unit for Illuminance.
- See Also
Meter
Gets the SI base unit for Length.
public static IBaseUnit Meter { get; }
Property Value
- IBaseUnit
The SI base unit for Length.
- See Also
Mole
Gets the SI base unit for Amount of Substance.
public static IBaseUnit Mole { get; }
Property Value
- IBaseUnit
The SI base unit for Amount of Substance.
- See Also
Name
Gets the name of this unit.
public string Name { get; }
Property Value
- String
The name of this unit.
Newton
Gets the SI unit for Force.
public static IBaseUnit Newton { get; }
Property Value
- IBaseUnit
The SI unit for Force.
- See Also
Ohm
Gets the SI unit for Electric Resistance.
public static IBaseUnit Ohm { get; }
Property Value
- IBaseUnit
The SI unit for Electric Resistance.
- See Also
Pascal
Gets the SI unit for Pressure.
public static IBaseUnit Pascal { get; }
Property Value
- IBaseUnit
The SI unit for Pressure.
- See Also
Radian
Gets the SI unit for Plane Angle.
public static IBaseUnit Radian { get; }
Property Value
- IBaseUnit
The SI unit for Plane Angle.
- See Also
Second
Gets the SI base unit for Time.
public static IBaseUnit Second { get; }
Property Value
- IBaseUnit
The SI base unit for Time.
- See Also
Siemens
Gets the SI unit for Electric Conductance.
public static IBaseUnit Siemens { get; }
Property Value
- IBaseUnit
The SI unit for Electric Conductance.
- See Also
Sievert
Gets the SI unit for Equivalent Dose.
public static IBaseUnit Sievert { get; }
Property Value
- IBaseUnit
The SI unit for Equivalent Dose.
- See Also
Steradian
Gets the SI unit for Solid Angle.
public static IBaseUnit Steradian { get; }
Property Value
- IBaseUnit
The SI unit for Solid Angle.
- See Also
Symbol
Gets the symbol of this unit.
public string Symbol { get; }
Property Value
- String
The symbol of this unit.
Tesla
Gets the SI unit for Magnetic Flux Density.
public static IBaseUnit Tesla { get; }
Property Value
- IBaseUnit
The SI unit for Magnetic Flux Density.
- See Also
Value
Gets the value of this unit expressed as bytes.
public double Value { get; }
Property Value
- Double
The value of this unit.
Volt
Gets the SI unit for Electric Potential.
public static IBaseUnit Volt { get; }
Property Value
- IBaseUnit
The SI unit for Electric Potential.
- See Also
Watt
Gets the SI unit for Power.
public static IBaseUnit Watt { get; }
Property Value
- IBaseUnit
The SI unit for Power.
- See Also
Weber
Gets the SI unit for Magnetic Flux.
public static IBaseUnit Weber { get; }
Property Value
- IBaseUnit
The SI unit for Magnetic Flux.
- See Also
Methods
Equals(IUnit)
Indicates whether the current object is equal to another object of the same type.
public virtual bool Equals(IUnit other)
Parameters
other
IUnitAn object to compare with this object.
Returns
- Boolean
true
if the current object is equal to theother
parameter; otherwise,false
.
Equals(Object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
ObjectThe object to compare with the current object.
Returns
- Boolean
true
if the specified object is equal to the current object; otherwise,false
.
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
- Int32
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
ToString()
Returns a System.String that represents this instance.
public override string ToString()
Returns
- String
A System.String that represents this instance.
Operators
Implicit(Unit to Double)
Performs an implicit conversion from Unit to System.Double.
public static implicit operator double (Unit unit)
Parameters
Returns
- Double
A System.Double that is equivalent to
unit
.