/// <summary> /// Build an array of lists of <c>TestListIdentifier_t</c> records associated with each unique <c>TESTLISTID</c> value defined in the <c>TESTLISTIDS</c> /// table of the data dictionary. The array element is mapped to the <c>TESTLISTID</c> field of the table. /// </summary> /// <param name="testListIdentifiersDataTable">Reference to the <c>TESTLISTIDS</c> table of the data dictionary.</param> /// <returns>An array of lists of <c>TestListIdentifier_t</c> records associated with each unique <c>TESTLISTID</c> value in the <c>TESTLISTIDS</c> table /// of the data dictionary, if the parameters are valid; otherwise, null.</returns> private List <TestListIdentifier_t>[] BuildTestListIdentifierLists(DataDictionary.TESTLISTIDSDataTable testListIdentifiersDataTable) { // Local copy of the data table. List <TestListIdentifier_t>[] records; if (testListIdentifiersDataTable == 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 < testListIdentifiersDataTable.Count; recordIndex++) { iDCurrent = testListIdentifiersDataTable[recordIndex].TESTLISTID; if (iDCurrent > iDMax) { iDMax = iDCurrent; } } // Instantiate the lookup array. records = new List <TestListIdentifier_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 <TestListIdentifier_t>(); } // Populate the lookup table; int identifier; DataDictionary.TESTLISTIDSRow row; for (int recordIndex = 0; recordIndex < testListIdentifiersDataTable.Count; recordIndex++) { row = testListIdentifiersDataTable[recordIndex]; identifier = row.TESTLISTID; // Instantiate a new structure to contain the data and copy the data across. TestListIdentifier_t record = new TestListIdentifier_t(); record.TestListIdentifier = row.TESTLISTID; 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>TESTLIST</c> table of the data dictionary.</param> /// <param name="testListIdentifiersDataTable">Reference to the <c>TESTLISTIDS</c> table of the data dictionary. This table defines the self tests associated /// with each test list.</param> public TestListTable(DataDictionary.TESTLISTDataTable dataTable, DataDictionary.TESTLISTIDSDataTable testListIdentifiersDataTable) : base(dataTable) { if (testListIdentifiersDataTable == null) { return; } m_TestListDataTable = dataTable; m_TestListIdentifierLists = BuildTestListIdentifierLists(testListIdentifiersDataTable); AddSelfTestRecordLists(); }