using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace CLab { /// /// The Type class represents a CLab type /// TypeenumeratorsList represents an enumeration type with a list of valid states (domain) /// public class TypeEnumeration : Type { private List enumeratorList; /// /// Constructor /// /// Name of the type /// List of valid states for the type public TypeEnumeration(String typeName, List enumeratorsList) : base(typeName) { this.enumeratorList = enumeratorsList; } ///List of valid states for the type public List EnumeratorsList { get { return enumeratorList; } } ///A string representation of the valid states for the type in the form {value1, value2, value3, ... , valueN} public String GetDomain { get { String domain = "{"; for (int i = 0; i < this.enumeratorList.Count; i++) { domain += this.enumeratorList[i]; if (i < this.enumeratorList.Count - 1) domain += ", "; } domain += "}"; return domain; } } public override String ToString() { String list = "{"; for (int i = 0; i < this.enumeratorList.Count; i++) { list += this.enumeratorList[i]; if (i < this.enumeratorList.Count - 1) list += ","; } list += "}"; return (String.Format(" {0} {1}, {2}", TypeName, list, base.ToString())); } } }