(Inherits from MfObject)
Abstract class for singleton pattern Classes.
Classes such as MfFlagsAttribute are derived from MfSingletonBase
Name |
Description |
|
Constructor for Abstract Class MfSingletonBase. |
Name |
Description |
|
Gets a Singleton instance of derived class |
Name |
Description |
|
Adds MfAttribute extended items to extended classes. Inherited from MfObject. |
||
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. Inherited from MfObject. |
||
Sets current instance of singleton derived class to null. Abstract Method. |
||
Compares obj to current instance to see if they are the same. Inherited from MfObject. |
||
Gets an MfAttribute of the class. Inherited from MfObject. |
||
Gets a MfGenericList of MfAttribute that Contains the attributes for the current class instance. Inherited from MfObject. |
||
Gets A hash code for the current MfObject. Inherited from MfObject. |
||
Gets the instance of the Singleton. Protected Abstract method. |
||
Gets the zero-based index value of the position of MfAttribute within the instance of the class. Inherited from MfObject. |
||
Gets the Type for the for the Class .Inherited from MfObject. |
||
Gets if the current instance of class derived from MfSystemException has MfAttribute. Inherited from MfObject. |
||
Gets if current instance of object is of the same type. Inherited from MfObject. Inherited from MfObject. |
||
Get if the current class is an instance. Inherited from MfObject. |
||
Creates a shallow copy of the current MfObject instance. Inherited from MfObject. |
||
Gets a string representation of the MfObject. Inherited from MfObject. |
||
Verifies the the current object is set to an instance. Inherited from MfObject. |
||
VerifyIsNotInstance([MethodName, LineFile, LineNumber, Source]) |
Verifies the the current object is NOT set to an instance. Used in Static methods. Inherited from MfObject. |
MsgBox % SingletonHello.Instance.Message
SingletonHello.Instance.Value := "Way too cool!"
MsgBox % SingletonHello.Instance.Message
ExitApp
class SingletonHello extends MfSingletonBase
{
static _instance := Null ; Static var to contain the singleton instance
m_Value := Null
__New() {
base.__New()
this.m_Value := "Hello World"
}
; GetInstance() is required to be overridden from the SingletonBase base class
GetInstance() { ; Overrides base
if (MfNull.IsNull(SingletonHello._instance)) {
SingletonHello._instance := new SingletonHello()
}
return SingletonHello._instance
}
; DestroyInstance() is required to be overridden from the SingletonBase base class
DestroyInstance() {
SingletonHello._instance := Null ; Clears current instance and releases memory
}
; Properties Start
Value[]
{
get {
return this.m_Value
}
set {
this.m_Value := value
return this.m_Value
}
}
Message[]
{
get {
return MfString.Format("The Value is currently:'{0}'", this.Value)
}
set { ; Read-only Property
ex := new MfNotSupportedException(MfEnvironment.Instance.GetResourceString("NotSupportedException_readonly_Property"))
ex.SetProp(A_LineFile, A_LineNumber, A_ThisFunc)
throw ex
}
}
; Properties End
}