/// <summary> /// Build an array of lists of <c>GroupListIdentifier_t</c> records associated with each unique <c>GROUPLISTID</c> value defined in the <c>GROUPLISTIDS</c> /// table of the data dictionary. The array element is mapped to the <c>GROUPLISTID</c> field of the table. /// </summary> /// <param name="groupListIdentifiersDataTable">Reference to the <c>GROUPLISTIDS</c> table of the data dictionary.</param> /// <returns>An array of lists of <c>GroupListIdentifier_t</c> records associated with each unique <c>GROUPLISTID</c> value in the <c>GROUPLISTIDS</c> table /// of the data dictionary, if the parameters are valid; otherwise, null.</returns> private List <GroupListIdentifier_t>[] BuildGroupListIdentifierLists(DataDictionary.GROUPLISTIDSDataTable groupListIdentifiersDataTable) { // Local copy of the data table. List <GroupListIdentifier_t>[] records; if (groupListIdentifiersDataTable == null) { return(null); } try { // Determine the maximum value of the identifier field in the data table, it cannot be assumed that the table is sorted by identifier. int iDMax = 0; int iDCurrent = 0; for (int recordIndex = 0; recordIndex < groupListIdentifiersDataTable.Count; recordIndex++) { iDCurrent = groupListIdentifiersDataTable[recordIndex].GROUPLISTID; if (iDCurrent > iDMax) { iDMax = iDCurrent; } } // Instantiate the lookup array. records = new List <GroupListIdentifier_t> [iDMax + 1]; // Instantiate a generic list for each element of the array. for (int recordIndex = 0; recordIndex < iDMax + 1; recordIndex++) { records[recordIndex] = new List <GroupListIdentifier_t>(); } // Populate the lookup table; int identifier; DataDictionary.GROUPLISTIDSRow row; for (int recordIndex = 0; recordIndex < groupListIdentifiersDataTable.Count; recordIndex++) { row = groupListIdentifiersDataTable[recordIndex]; identifier = row.GROUPLISTID; // Instantiate a new structure to contain the data and copy the data across. GroupListIdentifier_t record = new GroupListIdentifier_t(); record.GroupListIdentifier = row.GROUPLISTID; record.SelfTestIdentifier = row.SELFTESTID; // Add the record to the correct element of the array. records[identifier].Add(record); } } catch (Exception) { return(null); } return(records); }
/// <summary> /// Initialize a new instance of the class. /// </summary> /// <param name="dataTable">Reference to the <c>GROUPLIST</c> table of the data dictionary.</param> /// <param name="groupListIdentifiersDataTable">Reference to the <c>GROUPLISTIDS</c> table of the data dictionary. This table defines the self tests associated /// with each self test group list.</param> public GroupListTable(DataDictionary.GROUPLISTDataTable dataTable, DataDictionary.GROUPLISTIDSDataTable groupListIdentifiersDataTable) : base(dataTable) { if (groupListIdentifiersDataTable == null) { return; } m_GroupListDataTable = dataTable; m_GroupListIdentifierLists = BuildGroupListIdentifierLists(groupListIdentifiersDataTable); AddSelfTestRecordLists(); }