/// <summary> /// Build an array of the list of <c>SelfTestIdentifier_t</c> records associated with each unique <c>SELFTESTID</c> value defined in the <c>SELFTESTIDS</c> /// table of the data dictionary. The array element is mapped to the <c>SELFTESTID</c> field of the table. /// </summary> /// <param name="selfTestIdentifiersDataTable">Reference to the <c>SELFTESTIDS</c> data table of the data dictionary.</param> /// <returns>An array of lists of <c>SelfTestIdentifier_t</c> records associated with each unique <c>SELFTESTID</c> value in the <c>SELFTESTIDS</c> table of the /// data dictionary, if the parameters are valid; otherwise, null.</returns> protected virtual List <SelfTestIdentifier_t>[] BuildSelfTestIdentifierLists(DataDictionary.SELFTESTIDSDataTable selfTestIdentifiersDataTable) { // Local copy of the data table. List <SelfTestIdentifier_t>[] records; if (selfTestIdentifiersDataTable == 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 < selfTestIdentifiersDataTable.Count; recordIndex++) { iDCurrent = selfTestIdentifiersDataTable[recordIndex].SELFTESTID; if (iDCurrent > iDMax) { iDMax = iDCurrent; } } // Instantiate the lookup array. records = new List <SelfTestIdentifier_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 <SelfTestIdentifier_t>(); } // Populate the lookup table; int identifier; DataDictionary.SELFTESTIDSRow row; for (int recordIndex = 0; recordIndex < selfTestIdentifiersDataTable.Count; recordIndex++) { row = selfTestIdentifiersDataTable[recordIndex]; identifier = row.SELFTESTID; // Instantiate a new structure to contain the data and copy the data across. SelfTestIdentifier_t record = new SelfTestIdentifier_t(); record.SelfTestIdentifier = row.SELFTESTID; record.SelfTestNumber = row.SELFTESTNUMBER; record.SelfTestVariableIdentifier = row.SELFTESTVARID; // Add the record to the correct element of the array. records[identifier].Add(record); } } catch (Exception) { return(null); } return(records); }
/// <summary> /// Build the array that is used to access the list of <c>SelfTestIdentifier</c> records associated with a specified self test identifier. /// Build an array of lists of <c>SelfTestIdentifier_t</c> records associated with each unique <c>SELFTESTID</c> value defined in the <c>SELFTESTIDS</c> /// table of the data dictionary. The array element is mapped to the <c>SELFTESTNUMBER</c> field of the table. /// </summary> /// <param name="selfTestIdentifiersDataTable">Reference to the <c>SELFTESTIDS</c> data table of the data dictionary.</param> /// <returns>An array of lists of <c>SelfTestIdentifier_t</c> records associated with each unique <c>SELFTESTID</c> value in the <c>SELFTESTIDS</c> table of the /// data dictionary, if the parameters are valid; otherwise, null.</returns> protected override List<SelfTestIdentifier_t>[] BuildSelfTestIdentifierLists(DataDictionary.SELFTESTIDSDataTable selfTestIdentifiersDataTable) { // Local copy of the data table. List<SelfTestIdentifier_t>[] records; if (selfTestIdentifiersDataTable == 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 < selfTestIdentifiersDataTable.Count; recordIndex++) { iDCurrent = selfTestIdentifiersDataTable[recordIndex].SELFTESTNUMBER; if (iDCurrent > iDMax) { iDMax = iDCurrent; } } // Instantiate the lookup array. records = new List<SelfTestIdentifier_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<SelfTestIdentifier_t>(); } // Populate the lookup table; int identifier; DataDictionary.SELFTESTIDSRow row; for (int recordIndex = 0; recordIndex < selfTestIdentifiersDataTable.Count; recordIndex++) { row = selfTestIdentifiersDataTable[recordIndex]; identifier = row.SELFTESTNUMBER; // Instantiate a new structure to contain the data and copy the data across. SelfTestIdentifier_t record = new SelfTestIdentifier_t(); record.SelfTestIdentifier = row.SELFTESTID; record.SelfTestNumber = row.SELFTESTNUMBER; record.SelfTestVariableIdentifier = row.SELFTESTVARID; // Add the record to the correct element of the array. records[identifier].Add(record); } } catch (Exception) { return null; } return records; }