Class CommodityType
- Namespace
- NanoQL.Experimental
- Assembly
- NanoQL.dll
A commodity type: its name and code, such as "Heating Oil" and "HO".
[Experimental("NQL0001")]
public class CommodityType : IEquatable<CommodityType>
- Inheritance
-
CommodityType
- Implements
- Derived
- Inherited Members
Remarks
Immutable, and an extension point: NullCommodityType derives from it, and a user may build one.
QuantLib's empty CommodityType(), a placeholder whose members throw, is a CommodityType? null.
QuantLib keeps a process-wide registry keyed by code, so a second construction with a known code returns the first
construction's name whatever it was given (commoditytype.cpp:28-38). There is no registry here, so every type
holds the data it is given, a documented divergence (Divergences/CommodityRegistryTests.cs).
Two types are equal when their codes are, compared ordinally, as QuantLib's operator== compares them
(commoditytype.hpp:107-109); the hash is the code's. The equality is sealed.
Constructors
CommodityType(string, string)
Initializes a new instance of the CommodityType class.
public CommodityType(string name, string code)
Parameters
Exceptions
- ArgumentNullException
A string is null.
Properties
Code
Gets the type's code, such as "HO".
public string Code { get; }
Property Value
Name
Gets the type's name, such as "Heating Oil".
public string Name { get; }
Property Value
Methods
Equals(CommodityType?)
public bool Equals(CommodityType? other)
Parameters
otherCommodityType
Returns
Equals(object?)
public override sealed bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override sealed int GetHashCode()
Returns
ToString()
The type's code, as QuantLib's operator<< writes it.
public override string ToString()
Returns
- string
The code.
Operators
operator ==(CommodityType?, CommodityType?)
Whether two types are equal: their codes are.
public static bool operator ==(CommodityType? left, CommodityType? right)
Parameters
leftCommodityTypeA type, or null.
rightCommodityTypeAnother type, or null.
Returns
operator !=(CommodityType?, CommodityType?)
Whether two types differ.
public static bool operator !=(CommodityType? left, CommodityType? right)
Parameters
leftCommodityTypeA type, or null.
rightCommodityTypeAnother type, or null.
Returns
- bool
The negation of
==.