Overrides MfObject.CompareTo()
OutputVar := instance.CompareTo(obj)
Compares the current instance with another object derived from MfEnum or MfEnum.EnumItem Instance and returns an integer that indicates whether the current instance Value precedes, follows, or occurs in the same position in the sort order as the other object.
This method can be overridden in extended classes.
obj
Can be MfEnum or MfEnum.EnumItem Instance
Returns A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes obj in the sort order. Zero This instance occurs in the same position in the sort order as obj Greater than zero This instance follows obj in the sort order.
Throws MfNullReferenceException if instance enum is not an instance.
Throws MfArgumentNullException if obj is null.
Throws MfArgumentException if obj is not an derived from MfEnum or MfEnum.EnumItem Instance.
; create an instance of RegOptEnum and set Value to AutoresponseRegSz
myEnum := new RegOptEnum(RegOptEnum.Instance.AutoresponseRegSz)
myResult := myEnum.CompareTo(RegOptEnum.Instance.AutoupdateRegBinary)
; myResult is -1
MsgBox %myResult%
myResult := myEnum.CompareTo(RegOptEnum.Instance.KeysRegDword)
; myResult is 1
MsgBox %myResult%
myResult := myEnum.CompareTo(RegOptEnum.Instance.AutoresponseRegSz)
; myResult is 0
MsgBox %myResult%
ExitApp
; create a new enumeration class by inheriting/extending the MfEnum
class RegOptEnum extends MfEnum
{
static m_Instance := MfNull.Null
__New(args*)
{
if (this.base.__Class != "RegOptEnum")
{
throw new MfNotSupportedException(MfEnvironment.Instance.GetResourceString("NotSupportedException_Sealed_Class"
,"RegOptEnum"))
}
base.__New(args*)
; set MfObject m_isInherited flag for testing if Class is inherited/extended if needed
; This could be set to false as this class cannot be inherited/extended as set in this constructor above
; but will do it the standard way.
this.m_isInherited := this.__Class != "RegOptEnum"
}
; override the base AddEnums, this is required
; add all the enum values for your enum here
AddEnums() {
this.AddEnumValue("RegDword", 0)
this.AddEnumValue("KeysRegDword", 1)
this.AddEnumValue("RegSz", 2)
this.AddEnumValue("KeysRegSz", 3)
this.AddEnumValue("RegBinary", 4)
this.AddEnumValue("KeysRegBinary", 5)
this.AddEnumValue("AutoresponseRegSz", 6)
this.AddEnumValue("KeysAutoresponseRegSz", 7)
this.AddEnumValue("AutoupdateRegSz", 8)
this.AddEnumValue("KeysAutoupdateRegSz", 9)
this.AddEnumValue("AutoupdateRegBinary", 10)
this.AddEnumValue("KeysAutoupdateRegBinary", 11)
this.AddEnumValue("KeypathsRegSz", 12)
this.AddEnumValue("KeysKeypathsRegSz", 13)
this.AddEnumValue("KeypathsRegDword", 14)
this.AddEnumValue("KeysKeypathsRegDword", 15)
this.AddEnumValue("WindowplacementRegBinary", 16)
this.AddEnumValue("KeysWindowplacementRegBinary", 17)
}
; override the base DestroyInstance, this is required
DestroyInstance() {
RegOptEnum.m_Instance := Null
}
; override the base GetInstance, this is required
; Get a static default instance, create if not exist yet
GetInstance() {
if (MfNull.IsNull(RegOptEnum.m_Instance))
{
RegOptEnum.m_Instance := new RegOptEnum(0)
}
return RegOptEnum.m_Instance
}
}