当前位置: 首页>>代码示例>>C#>>正文


C# Database.Import方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:27,代码来源:Binder.cs

示例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));
            }
        }
开发者ID:zooba,项目名称:wix3,代码行数:28,代码来源:Binder.cs

示例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);
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:49,代码来源:Binder.cs


注:本文中的Microsoft.Tools.WindowsInstallerXml.Msi.Database.Import方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。