/// <summary> /// Add a row to the <paramref name="index"/> using the primary key. /// </summary> /// <param name="index">The indexed rows.</param> /// <param name="row">The row to index.</param> private void AddIndexedRow(IDictionary index, Row row) { string primaryKey = row.GetPrimaryKey('/'); if (null != primaryKey) { // Overriding WixActionRows have a primary key defined and take precedence in the index. if (row is WixActionRow) { WixActionRow currentRow = (WixActionRow)row; if (index.Contains(primaryKey)) { // If the current row is not overridable, see if the indexed row is. if (!currentRow.Overridable) { WixActionRow indexedRow = index[primaryKey] as WixActionRow; if (null != indexedRow && indexedRow.Overridable) { // The indexed key is overridable and should be replaced // (not removed and re-added which results in two Array.Copy // operations for SortedList, or may be re-hashing in other // implementations of IDictionary). index[primaryKey] = currentRow; } } // If we got this far, the row does not need to be indexed. return; } } // Nothing else should be added more than once. if (!index.Contains(primaryKey)) { index.Add(primaryKey, row); } else if (this.showPedanticMessages) { this.OnMessage(WixWarnings.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, row.Table.Name)); } } else // use the string representation of the row as its primary key (it may not be unique) { // this is provided for compatibility with unreal tables with no primary key // all real tables must specify at least one column as the primary key primaryKey = row.ToString(); index[primaryKey] = row; } }
/// <summary> /// Index an element by its corresponding row. /// </summary> /// <param name="row">The row corresponding to the element.</param> /// <param name="element">The element to index.</param> public void IndexElement(Row row, Wix.ISchemaElement element) { this.elements.Add(String.Concat(row.TableDefinition.Name, ':', row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)), element); }
/// <summary> /// Gets the element corresponding to the row it came from. /// </summary> /// <param name="row">The row corresponding to the element.</param> /// <returns>The indexed element.</returns> public Wix.ISchemaElement GetIndexedElement(Row row) { return(this.GetIndexedElement(row.TableDefinition.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter))); }
/// <summary> /// Gets the element corresponding to the row it came from. /// </summary> /// <param name="row">The row corresponding to the element.</param> /// <returns>The indexed element.</returns> public ISchemaElement GetIndexedElement(Row row) { return(this.GetIndexedElement(row.TableDefinition.Name, row.GetPrimaryKey(PrimaryKeyDelimiter))); }