RemoveFlag()
Removes a flag value from the current Value of MfEnum instance.
flag
The flag to add represented as var containing integer or an instance of MfEnum or MfEnum.EnumItem.
Throws MfNullReferenceException if derived MfEnum is not an instance.
Throws MfNotSupportedException if derived MfEnum does not Implement MfFlagsAttribute class.
Throws MfArgumentException if flag is incorrect type.
Throws MfArgumentException if flag is null.
; create new Enum Instance
myEnum := new RenderType()
; add flags
myEnum.AddFlag(RenderType.Instance.ViewPage)
myEnum.AddFlag(RenderType.Instance.GZip)
myEnum.AddFlag(RenderType.Instance.DataUri)
msg := GetMessage(myEnum) ; msg contains view, datauri, gzip
MsgBox %msg%
; remove a flag
myEnum.RemoveFlag(RenderType.Instance.DataUri)
msg := GetMessage(myEnum) ; msg contains view, gzip
MsgBox %msg%
ExitApp
GetMessage(byref RtEnum) {
retval := "MsgBox Valid combination of flags not found"
if (RtEnum.HasFlag(RenderType.Instance.ContentPage)
&& RtEnum.HasFlag(RenderType.Instance.DataUri)
&& RtEnum.HasFlag(RenderType.Instance.GZip))
{
retval := "content, datauri, gzip"
}
else if (RtEnum.HasFlag(RenderType.Instance.ContentPage)
&& RtEnum.HasFlag(RenderType.Instance.GZip))
{
retval := "content, gzip"
}
else if (RtEnum.HasFlag(RenderType.Instance.ContentPage))
{
retval := "content"
}
else if (RtEnum.HasFlag(RenderType.Instance.ViewPage)
&& RtEnum.HasFlag(RenderType.Instance.DataUri)
&& RtEnum.HasFlag(RenderType.Instance.GZip))
{
retval := "view, datauri, gzip"
}
else if (RtEnum.HasFlag(RenderType.Instance.ViewPage)
&& RtEnum.HasFlag(RenderType.Instance.GZip))
{
retval := "view, gzip"
}
else if (RtEnum.HasFlag(RenderType.Instance.ViewPage))
{
retval := "view"
}
else if (RtEnum.HasFlag(RenderType.Instance.HomePage)
&& RtEnum.HasFlag(RenderType.Instance.DataUri)
&& RtEnum.HasFlag(RenderType.Instance.GZip))
{
retval := "home, datauri, gzip"
}
else if (RtEnum.HasFlag(RenderType.Instance.HomePage)
&& RtEnum.HasFlag(RenderType.Instance.GZip))
{
retval := "home, gzip"
}
else if (RtEnum.HasFlag(RenderType.Instance.HomePage))
{
retval := "home"
}
else if (RtEnum.Equals(RenderType.Instance.None))
{
retval := "Flags not set"
}
return retval
}
; create a new enumeration class by inheriting/extending the MfEnum
class RenderType extends MfEnum
{
static m_Instance := MfNull.Null
__New(args*)
{
if (this.base.__Class != "RenderType")
{
throw new MfNotSupportedException(MfEnvironment.Instance.GetResourceString("NotSupportedException_Sealed_Class"
, "RenderType"))
}
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 != "RenderType"
}
; override the base AddEnums, this is required
; add all the enum values for your enum here
AddEnums() {
this.AddEnumValue("None", 0)
this.AddEnumValue("DataUri", 1)
this.AddEnumValue("GZip", 2)
this.AddEnumValue("ContentPage", 4)
this.AddEnumValue("ViewPage", 8)
this.AddEnumValue("HomePage", 16)
}
; override the base AddAttributes and add flags
AddAttributes()
{
flags := new MfFlagsAttribute()
this.AddAttribute(flags)
}
; override the base DestroyInstance, this is required
DestroyInstance()
{
RenderType.m_Instance := MfNull.Null
}
; override the base GetInstance, this is required
; Get a static default instance, create if not exist yet
GetInstance()
{
if (MfNull.IsNull(RenderType.m_Instance))
{
RenderType.m_Instance := new RenderType(0)
}
return RenderType.m_Instance
}
}