/// <summary> /// Indexer for for List /// </summary> /// <param name="TableElementType">TableElementType of the TableElement</param> /// <param name="Number">Number of TheTableElement</param> /// <returns>TableElement with specified TableElementType and Number</returns> public TableElement this[TableElementTypeEnum TableElementType, int Number] { get { return(_TableElementsDictionary[TableElementType][Number]); } }
/// <summary> /// Initializes a new instance of the <see cref="TableElement"/> class with the specified parameters. /// </summary> /// <param name="TableElementType">Type of the TableElement.</param> /// <param name="Number">The number of the TableElement.</param> /// <param name="Value">The value of the TableElement.</param> public TableElement(TableElementTypeEnum TableElementType, int Number, int Value) : this() { this.TableElementType = TableElementType; this.Number = Number; this.Value = Value; }
/// <summary> /// Initializes a new instance of the <see cref="TableElementData"/> class from the data in a TableElement. /// </summary> /// <param name="TableElement">The table element containg the data.</param> public TableElementData(TableElement TableElement) { this.Number = TableElement.Number; this.TableElementType = TableElement.TableElementType; this.Name = TableElement.Name; this.Value = TableElement.Value; }
/// <summary> /// Initializes a new instance of the <see cref="TableElementData"/> class. /// </summary> /// <param name="TableElementType">Type of the table element as defined in TableElementTypeEnum.</param> /// <param name="Number">The number of the table element.</param> /// <param name="Value">The value of the table element.</param> public TableElementData(TableElementTypeEnum TableElementType, int Number, int Value) { this.TableElementType = TableElementType; this.Number = Number; this.Value = Value; this.Name = null; }
///// <summary> ///// Returns a dictionary for the specified TableElementType ///// </summary> //public Dictionary<int, TableElement> GetTableElementDictonaryForType(TableElementTypeEnum Type) //{ // return _NumberedTableElementsDictionary[Type]; //} /// <summary> /// Returns a list of the TableElement objects with the specified type.<br/> /// \note This method does internaly create a new list of the specified table elements on every call. This is not very fast. /// </summary> public List <TableElement> GetTableElementListForType(TableElementTypeEnum Type) { if (Type == TableElementTypeEnum.NamedElement) { return(new List <TableElement>(_NamedTableElementsDictionary.Values)); } else { return(new List <TableElement>(_NumberedTableElementsDictionary[Type].Values)); } }
/// <summary> /// Indexer for for List /// </summary> /// <param name="TableElementType">TableElementType of the TableElement</param> /// <param name="Number">Number of TheTableElement</param> /// <returns>TableElement with specified TableElementType and Number</returns> public TableElement this[TableElementTypeEnum TableElementType, int Number] { get { if (TableElementType == TableElementTypeEnum.NamedElement) { throw new IndexOutOfRangeException("Table element type NamedElement cant be retrieved by number."); } return(_NumberedTableElementsDictionary[TableElementType][Number]); } }
/// <summary> /// Removes the TableElement with the specified TableElementType and Number from the list. /// </summary> /// <param name="TableElementType">TableElementType of the TableElement to remove.</param> /// <param name="Number">Number of the TableElement to remove.</param> public bool Remove(TableElementTypeEnum TableElementType, int Number) { if (!Contains(TableElementType, Number)) { return(false); } Remove(_TableElementsDictionary[TableElementType][Number]); _TableElementsDictionary[TableElementType].Remove(Number); return(true); }
/// <summary> /// Method to update the state and/or add a entry to the list /// </summary> /// <param name="TableElementType">Type of entry to update</param> /// <param name="Number">Number of entry to update</param> /// <param name="State">State of entry to update</param> public void UpdateState(TableElementTypeEnum TableElementType, int Number, int State) { if (Contains(TableElementType, Number)) { _TableElementsDictionary[TableElementType][Number].Value = State; } else { Add(TableElementType, Number, State); } }
/// <summary> /// Initializes a new instance of the <see cref="TableElementData"/> class. /// </summary> /// <param name="TableElementTypeChar">Single character specifing the type of the table element. Valid values are the enum values in TableElementTypeEnum.</param> /// <param name="Number">The number of the table element.</param> /// <param name="Value">The value of the table element.</param> public TableElementData(Char TableElementTypeChar, int Number, int Value) { if (!Enum.IsDefined(typeof(TableElementTypeEnum), (int)TableElementTypeChar)) { Log.Warning("Undefined char \"{0}\" supplied for the TableElementTypeChar.".Build(TableElementTypeChar)); this.TableElementType = TableElementTypeEnum.Unknown; } else { this.TableElementType = (TableElementTypeEnum)TableElementTypeChar; } this.Number = Number; this.Name = null; this.Value = Value; }
public TableElementData(string TableElementName, int Value) { if (TableElementName.Length > 1 && Enum.IsDefined(typeof(TableElementTypeEnum), (int)TableElementName[0]) && TableElementName[0] != (char)TableElementTypeEnum.NamedElement && TableElementName.Substring(1).IsInteger()) { //It is a normal table element. this.TableElementType = (TableElementTypeEnum)TableElementName[0]; this.Number = TableElementName.Substring(1).ToInteger(); this.Name = null; } else { //Named table element this.TableElementType = TableElementTypeEnum.NamedElement; this.Name = (TableElementName[0] != (char)TableElementTypeEnum.NamedElement?TableElementName:TableElementName.Substring(1)); this.Number = int.MinValue; } this.Value = Value; }
/// <summary> /// Checks if a specified TableElement is contained in the list. /// </summary> /// <param name="TableElementType">Type of the TableElement to check.</param> /// <param name="Number">Number of TableElement to check.</param> /// <returns>true/false</returns> public bool Contains(TableElementTypeEnum TableElementType, int Number) { return(_NumberedTableElementsDictionary[TableElementType].ContainsKey(Number)); }
/// <summary> /// Method for adding a entry to the list. /// </summary> /// <param name="TableElementType">Type of entry to add.</param> /// <param name="Number">Number of entry to add.</param> /// <param name="State">State of entry to add.</param> /// <exception cref="System.Exception"> /// Cant add null to the list of table elements /// or /// The TableElement {Type} {Number} cant be added to the list. Another entry with the same type and number does already exist. /// </exception> public void Add(TableElementTypeEnum TableElementType, int Number, int State) { Add(new TableElement(TableElementType, Number, State)); }
/// <summary> /// Returns a list of the TableElement objects with the specified type.<br/> /// \note This method does internaly create a new list of the specified table elements on every call. This is not very fast. /// </summary> public List <TableElement> GetTableElementListForType(TableElementTypeEnum Type) { return(new List <TableElement> (_TableElementsDictionary[Type].Values)); }
/// <summary> /// Returns a dictionary for the specified TableElementType /// </summary> public Dictionary <int, TableElement> GetTableElementDictonaryForType(TableElementTypeEnum Type) { return(_TableElementsDictionary[Type]); }