Class Unit
- Namespace
- StockSharp.Messages
- Assembly
- StockSharp.Messages.dll
Special class, allows to set the value as a percentage, absolute, points and pips values.
[DataContract]
public class Unit : Equatable<Unit>, IOperable<Unit>, IComparable<Unit>, IPersistable, IFormattable
- Inheritance
-
Unit
- Implements
-
IOperable<Unit>IPersistable
- Extension Methods
Constructors
Unit()
Create unit.
public Unit()
Unit(decimal)
Create absolute value Absolute.
public Unit(decimal value)
Parameters
value
decimalValue.
Unit(decimal, UnitTypes)
public Unit(decimal value, UnitTypes type)
Parameters
Unit(decimal, UnitTypes, Func<UnitTypes, decimal?>)
public Unit(decimal value, UnitTypes type, Func<UnitTypes, decimal?> getTypeValue)
Parameters
value
decimalValue.
type
UnitTypesMeasure unit.
getTypeValue
Func<UnitTypes, decimal?>The handler returns a value associated with Type (price or volume steps).
Properties
GetTypeValue
The handler returns a value associated with Type (price or volume steps).
public Func<UnitTypes, decimal?> GetTypeValue { get; set; }
Property Value
Type
Measure unit.
[DataMember]
public UnitTypes Type { get; set; }
Property Value
Value
Value.
[DataMember]
public decimal Value { get; set; }
Property Value
Methods
Clone()
Create a copy of Unit.
public override Unit Clone()
Returns
- Unit
Copy.
CompareTo(Unit)
Compare Unit on the equivalence.
public override int CompareTo(Unit other)
Parameters
other
UnitAnother value with which to compare.
Returns
- int
The result of the comparison.
Convert(UnitTypes, bool)
Cast the value to another type.
public Unit Convert(UnitTypes destinationType, bool throwException = true)
Parameters
destinationType
UnitTypesDestination value type.
throwException
boolThrow exception in case of impossible conversion. Otherwise, returns null.
Returns
- Unit
Converted value.
Convert(UnitTypes, Func<UnitTypes, decimal?>, bool)
Cast the value to another type.
public Unit Convert(UnitTypes destinationType, Func<UnitTypes, decimal?> getTypeValue, bool throwException = true)
Parameters
destinationType
UnitTypesDestination value type.
getTypeValue
Func<UnitTypes, decimal?>The handler returns a value associated with Type (price or volume steps).
throwException
boolThrow exception in case of impossible conversion. Otherwise, returns null.
Returns
- Unit
Converted value.
Equals(object)
Compare Unit on the equivalence.
public override bool Equals(object other)
Parameters
other
objectAnother value with which to compare.
Returns
GetHashCode()
Get the hash code of the object Unit.
public override int GetHashCode()
Returns
- int
A hash code.
GetTypeSuffix(UnitTypes)
Get string suffix.
public static string GetTypeSuffix(UnitTypes type)
Parameters
type
UnitTypesMeasure unit.
Returns
- string
String suffix.
Load(SettingsStorage)
Load settings.
public void Load(SettingsStorage storage)
Parameters
storage
SettingsStorageSettings storage.
OnEquals(Unit)
Compare Unit on the equivalence.
protected override bool OnEquals(Unit other)
Parameters
other
UnitAnother value with which to compare.
Returns
Save(SettingsStorage)
Save settings.
public void Save(SettingsStorage storage)
Parameters
storage
SettingsStorageSettings storage.
ToString()
public override string ToString()
Returns
ToString(string, IFormatProvider)
public string ToString(string format, IFormatProvider formatProvider)
Parameters
format
stringformatProvider
IFormatProvider
Returns
Operators
operator +(Unit, Unit)
Add the two objects Unit.
public static Unit operator +(Unit u1, Unit u2)
Parameters
Returns
- Unit
The result of addition.
operator /(Unit, Unit)
Divide the unit Unit to another.
public static Unit operator /(Unit u1, Unit u2)
Parameters
Returns
- Unit
The result of the division.
operator ==(Unit, Unit)
Compare two values for equality (if the value of different types, the conversion will be used).
public static bool operator ==(Unit u1, Unit u2)
Parameters
Returns
explicit operator decimal(Unit)
public static explicit operator decimal(Unit unit)
Parameters
Returns
explicit operator double(Unit)
public static explicit operator double(Unit unit)
Parameters
Returns
explicit operator decimal?(Unit)
public static explicit operator decimal?(Unit unit)
Parameters
Returns
explicit operator double?(Unit)
public static explicit operator double?(Unit unit)
Parameters
Returns
operator >(Unit, Unit)
Check whether the first value is greater than the second.
public static bool operator >(Unit u1, Unit u2)
Parameters
Returns
operator >=(Unit, Unit)
Check whether the first value is greater than or equal to the second.
public static bool operator >=(Unit u1, Unit u2)
Parameters
Returns
implicit operator Unit(decimal)
public static implicit operator Unit(decimal value)
Parameters
Returns
implicit operator Unit(double)
public static implicit operator Unit(double value)
Parameters
Returns
implicit operator Unit(int)
public static implicit operator Unit(int value)
Parameters
Returns
operator !=(Unit, Unit)
Compare two values in the inequality (if the value of different types, the conversion will be used).
public static bool operator !=(Unit u1, Unit u2)
Parameters
Returns
operator <(Unit, Unit)
Check whether the first value is less than the second.
public static bool operator <(Unit u1, Unit u2)
Parameters
Returns
operator <=(Unit, Unit)
Check whether the first value is less than or equal to the second.
public static bool operator <=(Unit u1, Unit u2)
Parameters
Returns
operator *(Unit, Unit)
Multiply the two objects Unit.
public static Unit operator *(Unit u1, Unit u2)
Parameters
Returns
- Unit
The result of the multiplication.
operator -(Unit, Unit)
Subtract the unit Unit from another.
public static Unit operator -(Unit u1, Unit u2)
Parameters
Returns
- Unit
The result of the subtraction.
operator -(Unit)
Get the value with the opposite sign from the value Value.
public static Unit operator -(Unit u)
Parameters
u
UnitUnit.
Returns
- Unit
Opposite value.