本文整理汇总了C#中Microsoft.Tools.WindowsInstallerXml.Msi.Database.PrimaryKeys方法的典型用法代码示例。如果您正苦于以下问题:C# Database.PrimaryKeys方法的具体用法?C# Database.PrimaryKeys怎么用?C# Database.PrimaryKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Tools.WindowsInstallerXml.Msi.Database
的用法示例。
在下文中一共展示了Database.PrimaryKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnbindDatabase
/// <summary>
/// Unbind an MSI database file.
/// </summary>
/// <param name="databaseFile">The database file.</param>
/// <param name="database">The opened database.</param>
/// <param name="outputType">The type of output to create.</param>
/// <param name="exportBasePath">The path where files should be exported.</param>
/// <param name="skipSummaryInfo">Option to skip unbinding the _SummaryInformation table.</param>
/// <returns>The output representing the database.</returns>
private Output UnbindDatabase(string databaseFile, Database database, OutputType outputType, string exportBasePath, bool skipSummaryInfo)
{
string modularizationGuid = null;
Output output = new Output(SourceLineNumberCollection.FromFileName(databaseFile));
View validationView = null;
// set the output type
output.Type = outputType;
// get the codepage
database.Export("_ForceCodepage", this.TempFilesLocation, "_ForceCodepage.idt");
using (StreamReader sr = File.OpenText(Path.Combine(this.TempFilesLocation, "_ForceCodepage.idt")))
{
string line;
while (null != (line = sr.ReadLine()))
{
string[] data = line.Split('\t');
if (2 == data.Length)
{
output.Codepage = Convert.ToInt32(data[0], CultureInfo.InvariantCulture);
}
}
}
// get the summary information table if it exists; it won't if unbinding a transform
if (!skipSummaryInfo)
{
using (SummaryInformation summaryInformation = new SummaryInformation(database))
{
Table table = new Table(null, this.tableDefinitions["_SummaryInformation"]);
for (int i = 1; 19 >= i; i++)
{
string value = summaryInformation.GetProperty(i);
if (0 < value.Length)
{
Row row = table.CreateRow(output.SourceLineNumbers);
row[0] = i;
row[1] = value;
}
}
output.Tables.Add(table);
}
}
try
{
// open a view on the validation table if it exists
if (database.TableExists("_Validation"))
{
validationView = database.OpenView("SELECT * FROM `_Validation` WHERE `Table` = ? AND `Column` = ?");
}
// get the normal tables
using (View tablesView = database.OpenExecuteView("SELECT * FROM _Tables"))
{
while (true)
{
using (Record tableRecord = tablesView.Fetch())
{
if (null == tableRecord)
{
break;
}
string tableName = tableRecord.GetString(1);
using (View tableView = database.OpenExecuteView(String.Format(CultureInfo.InvariantCulture, "SELECT * FROM `{0}`", tableName)))
{
TableDefinition tableDefinition = new TableDefinition(tableName, false, false);
Hashtable tablePrimaryKeys = new Hashtable();
using (Record columnNameRecord = tableView.GetColumnInfo(MsiInterop.MSICOLINFONAMES),
columnTypeRecord = tableView.GetColumnInfo(MsiInterop.MSICOLINFOTYPES))
{
int columnCount = columnNameRecord.GetFieldCount();
// index the primary keys
using (Record primaryKeysRecord = database.PrimaryKeys(tableName))
{
int primaryKeysFieldCount = primaryKeysRecord.GetFieldCount();
for (int i = 1; i <= primaryKeysFieldCount; i++)
{
tablePrimaryKeys[primaryKeysRecord.GetString(i)] = null;
}
}
//.........这里部分代码省略.........