本文整理汇总了C#中Microsoft.Tools.WindowsInstallerXml.Msi.Database.Import方法的典型用法代码示例。如果您正苦于以下问题:C# Database.Import方法的具体用法?C# Database.Import怎么用?C# Database.Import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Tools.WindowsInstallerXml.Msi.Database
的用法示例。
在下文中一共展示了Database.Import方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDatabaseCodepage
/// <summary>
/// Sets the codepage of a database.
/// </summary>
/// <param name="db">Database to set codepage into.</param>
/// <param name="output">Output with the codepage for the database.</param>
private void SetDatabaseCodepage(Database db, Output output)
{
// write out the _ForceCodepage IDT file
string idtPath = String.Concat(this.tempFiles.BasePath, Path.DirectorySeparatorChar, "codepage.idt");
using (StreamWriter idtFile = new StreamWriter(idtPath, true, Encoding.ASCII))
{
idtFile.WriteLine(); // dummy column name record
idtFile.WriteLine(); // dummy column definition record
idtFile.Write(output.Codepage);
idtFile.WriteLine("\t_ForceCodepage");
}
// try to import the table into the MSI
try
{
db.Import(Path.GetDirectoryName(idtPath), Path.GetFileName(idtPath));
}
catch (System.Configuration.ConfigurationException ce)
{
throw new WixInvalidCodepageException(SourceLineNumberCollection.FromFileName(output.Path), output.Codepage, ce);
}
}
示例2: SetDatabaseCodepage
/// <summary>
/// Sets the codepage of a database.
/// </summary>
/// <param name="db">Database to set codepage into.</param>
/// <param name="output">Output with the codepage for the database.</param>
private void SetDatabaseCodepage(Database db, Output output)
{
// write out the _ForceCodepage IDT file
string idtPath = Path.Combine(this.TempFilesLocation, "_ForceCodepage.idt");
using (StreamWriter idtFile = new StreamWriter(idtPath, false, Encoding.ASCII))
{
idtFile.WriteLine(); // dummy column name record
idtFile.WriteLine(); // dummy column definition record
idtFile.Write(output.Codepage);
idtFile.WriteLine("\t_ForceCodepage");
}
// try to import the table into the MSI
try
{
db.Import(Path.GetDirectoryName(idtPath), Path.GetFileName(idtPath));
}
catch (WixInvalidIdtException)
{
// the IDT should be valid, so an invalid code page was given
throw new WixException(WixErrors.IllegalCodepage(output.Codepage));
}
}
示例3: ImportTable
/// <summary>
/// Imports a table into the database.
/// </summary>
/// <param name="db">Database to import table to.</param>
/// <param name="output">Output for current database.</param>
/// <param name="outputTable">Output table to import into database.</param>
private void ImportTable(Database db, Output output, OutputTable outputTable)
{
// write out the table to an IDT file
string idtPath = Path.Combine(this.tempFiles.BasePath, String.Concat(outputTable.Name, ".idt"));
StreamWriter idtWriter = null;
try
{
Encoding encoding = (0 == output.Codepage ? Encoding.ASCII : Encoding.GetEncoding(output.Codepage));
// this is a workaround to prevent the UTF-8 byte order marking (BOM)
// from being added to the beginning of the idt file - according to
// MSDN, the default encoding for StreamWriter is a special UTF-8
// encoding that returns an empty byte[] from GetPreamble
if (Encoding.UTF8 == encoding)
{
idtWriter = new StreamWriter(idtPath, false);
}
else
{
idtWriter = new StreamWriter(idtPath, false, encoding);
}
idtWriter.Write(outputTable.ToIdtDefinition(output.ModularizationGuid, 0 == output.IgnoreModularizations.Count ? null : output.IgnoreModularizations));
}
finally
{
if (null != idtWriter)
{
idtWriter.Close();
}
}
// try to import the table into the MSI
try
{
db.Import(Path.GetDirectoryName(idtPath), Path.GetFileName(idtPath));
}
catch (System.Configuration.ConfigurationException ce)
{
throw new WixInvalidIdtException(SourceLineNumberCollection.FromFileName(output.Path), outputTable.Name, idtPath, ce);
}
}