OutputVar := instance.HasFlag(flag)
Gets if the MfEnum extended class has a flag set
flag
A var containing integer or an instance extended from MfEnum.EnumItem
Returns true value if flag is set; Otherwise false.
Throws MfNullReferenceException if method is called on a non-instance.
Throws MfArgumentNullException if flag is null.
Throws MfNotSupportedException if MfFlagsAttribute is not implement on the extended MfEnum instance.
Throws MfArgumentException if flag is not correct for this MfEnum instance
; 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
}
}