MfDictionary

Namespace ›› System ››
Parent Previous Next

MfDictionary Class

(Inherits from MfDictionaryBase)

Provides class for a strongly typed collection of key/value pairs.

Links

Properties, Methods

Constructors


Name

Description

Constructor()

Constructor for MfDictionary Class

Constructor(capacity)

Constructs new instance of MfDictionary Class and sets the initial capacity.

Properties


Name

Description

Count

Gets the number of elements contained in the MfDictionaryBase instance.. This property cannot be overridden. Inherited from MfDictionaryBase

Dictionary

Gets the list of elements contained in the MfDictionaryBase instance Inherited from MfDictionaryBase

InnerHashtable

Gets the list of elements contained in the MfDictionaryBase instance. Inherited from MfDictionaryBase

IsFixedSize

Gets a value indicating whether the MfDictionary is a fixed size. Overrides MfDictionaryBase.IsFixedSize

IsReadonly

Gets a value indicating whether the MfDictionary is read-only. Overrides MfDictionaryBase.IsFixedSize

Item

Gets or sets the element at the specified index. Inherited from MfDictionaryBase

Keys

Gets an MfCollection instance containing the keys in the MfDictionaryBase instance. Inherited from MfDictionaryBase

Values

Gets an MfCollection instance containing the values in the MfDictionaryBase instance. Inherited from MfDictionaryBase

Methods


Name

Description

_NewEnum()

Returns a new enumerator to enumerate this object's key-value pairs. Overrides MfEnumerableBase._NewEnum()

Add(key, value)

Adds an element with the specified key and value into the MfDictionaryBase instance Inherited from MfDictionaryBase

AddAttribute()

Adds MfAttribute extended items to extended classes. Inherited from MfObject.

Clear()

Clears the contents of the MfDictionaryBase instance.. This method in not to be overridden. Inherited from MfDictionaryBase

CompareTo()

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.

Contains(key)

Determines whether the MfDictionaryBase contains a specific element. Inherited from MfDictionaryBase

Contains(obj)

Determines whether the MfCollectionBase contains a specific element. Inherited from MfDictionaryBase

Equals(obj)

Compares obj to current instance to see if they are the same. Inherited from MfObject.

GetAttribute(index)

Gets an MfAttribute of the class. Inherited from MfObject.

GetAttributes()

Gets a MfGenericList of MfAttribute that Contains the attributes for the current class instance. Inherited from MfObject.

GetEnumerator()

Gets an enumerator. Inherited from MfEnumerableBase

GetIndexOfAttribute(attrib)

Gets the zero-based index value of the position of MfAttribute within the instance of the class. Inherited from MfObject.

GetType()

Gets the Type for the for the Class .Inherited from MfObject.

HasAttribute(attrib)

Gets if the current instance of class derived from MfSystemException has MfAttribute. Inherited from MfObject.

Is(type)

Gets if current instance of object is of the same type. Inherited from MfObject. Inherited from MfObject.

IsInstance()

Get if the current class is an instance. Inherited from MfObject.

MemberwiseClone()

Creates a shallow copy of the current MfObject instance. Inherited from MfObject.

OnClear()

Performs additional custom processes when clearing the contents of the MfDictionaryBase instance Inherited from MfDictionaryBase

OnClearComplete()

Performs additional custom processes after clearing the contents of the MfDictionaryBase instance. Inherited from MfDictionaryBase

OnInsert(key, value)

Performs additional custom processes before inserting a new element into the MfDictionaryBase instance. Inherited from MfDictionaryBase

OnInsertComplete(key, value)

Performs additional custom processes after inserting a new element into the MfDictionaryBase instance. Inherited from MfDictionaryBase

OnRemove(key, value)

Performs additional custom processes before removing an element from the current instance. Inherited from MfDictionaryBase

OnRemoveComplete(key, value)

Performs additional custom processes after removing an element from the MfDictionaryBase instance. Inherited from MfDictionaryBase

OnSet(key, oldValue, newValue)

Performs additional custom processes before setting a value in the MfDictionaryBase instance. Inherited from MfDictionaryBase

OnSetComplete(key, oldValue, newValue)

Performs additional custom processes after setting a value in the MfDictionaryBase instance. Inherited from MfDictionaryBase

OnValidate(value)

Performs additional custom processes when validating a value. Inherited from MfDictionaryBase

Remove(key)

Removes the first occurrence of a specific object from the MfDictionaryBase. Inherited from MfDictionaryBase

ToString()

Gets a string representation of the MfObject. Inherited from MfObject.

VerifyIsInstance([ClassName, LineFile, LineNumber, Source])

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.

Example

mfDic := new MfDictionary()
stud1 := new Student()
stud1.Id := "RT34TTTSV"
stud1.Name := "Frank Smith"
stud1.Age := 21
stud1.HomeRoom := "English 101"

mfDic.Add(stud1.Id, stud1)

stud2 := new Student()
stud2.Id := "WRT556SV"
stud2.Name := "Sue Smith"
stud2.Age := 20
stud2.HomeRoom := "French 102"

if (mfDic.Contains(stud2.id) = false)
{
   mfDic.Add(stud2.Id, stud2)
}
stud3 := new Student()
stud3.Id := "GTUFF7SV"
stud3.Name := "Bob Smith"
stud3.Age := 22
stud3.HomeRoom := "Math 201"

if (mfDic.Contains(stud3.Id) = false)
{
   mfDic.Add(stud3.Id, stud3)
}

MsgBox % mfDic.Item["GTUFF7SV"].HomeRoom ; Math 201

mfsHomeScience := new MfString("Science 504")
mfDic.Item["GTUFF7SV"].HomeRoom := mfsHomeScience

MsgBox % mfDic.Item["GTUFF7SV"].HomeRoom ; Science 504

MsgBox, 64, Student Count, % MfString.Format("There are currently {0} Students", mfDic.Count)
for key, st in mfDic
{
   st.EnrollmentYear := A_Year
}
MsgBox % mfDic.Item["WRT556SV"].EnrollmentYear

ExitApp

Class Student extends MfObject
{
   m_Id := ""
   m_Name := ""
   m_Age := 0
   m_HomeRoom := ""
   m_EnrollmentYear := 0

   Id[]
   {
       get {
           return this.m_Id
       }
       set {
           this.m_Id := MfString.GetValue(value)
           return this.m_Id
       }
   }

   Name[]
   {
       get {
           return this.m_Name
       }
       set {
           this.m_Name := MfString.GetValue(value)
           return this.m_Name
       }
   }

   Age[]
   {
       get {
           return this.m_Age
       }
       set {
           this.m_Age := MfInteger.GetValue(value, 0)
           return this.m_Age
       }
   }

   HomeRoom[]
   {
       get {
           return this.m_HomeRoom
       }
       set {
           this.m_HomeRoom := MfString.GetValue(value)
           return this.m_HomeRoom
       }
   }

   EnrollmentYear[]
   {
       get {
           return this.m_EnrollmentYear
       }
       set {
           this.m_EnrollmentYear := MfInteger.GetValue(value, 0)
           return this.m_EnrollmentYear
       }
   }

  ; Override ToString()
  ToString()
  {
       ; throw an error if called as static method
       this.VerifyIsInstance(this, A_LineFile, A_LineNumber, A_ThisFunc)
       return MfString.Format("ID:'{0}', Name:'{1}', Age:'{2}'", this.Id, this.Name, this.Age)
  }
}