本文整理汇总了C#中Microsoft.Deployment.WindowsInstaller.Record.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Record.ToString方法的具体用法?C# Record.ToString怎么用?C# Record.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Deployment.WindowsInstaller.Record
的用法示例。
在下文中一共展示了Record.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SeekRecordThenTryFormatString
public void SeekRecordThenTryFormatString()
{
string dbFile = "SeekRecordThenTryFormatString.msi";
using (Database db = new Database(dbFile, DatabaseOpenMode.CreateDirect))
{
WindowsInstallerUtils.InitializeProductDatabase(db);
WindowsInstallerUtils.CreateTestProduct(db);
string parameterFormatString = "[1]";
string[] properties = new string[]
{
"SonGoku", "Over 9000",
};
string query = "SELECT `Property`, `Value` FROM `Property`";
using (View view = db.OpenView(query))
{
using (Record rec = new Record(2))
{
rec[1] = properties[0];
rec[2] = properties[1];
rec.FormatString = parameterFormatString;
Console.WriteLine("Record fields before seeking: " + rec[0] + " " + rec[1] + " " + rec[2]);
view.Seek(rec);
//TODO: Why does view.Seek remove the record fields?
Console.WriteLine("Record fields after seeking: " + rec[0] + " " + rec[1] + " " + rec[2]);
// After inserting, the format string is invalid.
Assert.AreEqual(String.Empty, rec.ToString());
}
}
}
}
示例2: InsertRecordThenTryFormatString
public void InsertRecordThenTryFormatString()
{
string dbFile = "InsertRecordThenTryFormatString.msi";
using (Database db = new Database(dbFile, DatabaseOpenMode.CreateDirect))
{
WindowsInstallerUtils.InitializeProductDatabase(db);
WindowsInstallerUtils.CreateTestProduct(db);
string parameterFormatString = "[1]";
string[] properties = new string[]
{
"SonGoku", "Over 9000",
};
string query = "SELECT `Property`, `Value` FROM `Property`";
using (View view = db.OpenView(query))
{
using (Record rec = new Record(2))
{
rec[1] = properties[0];
rec[2] = properties[1];
rec.FormatString = parameterFormatString;
Console.WriteLine("Format String before inserting: " + rec.FormatString);
view.Insert(rec);
Console.WriteLine("Format String after inserting: " + rec.FormatString);
// After inserting, the format string is invalid.
Assert.AreEqual(String.Empty, rec.ToString());
// Setting the format string manually makes it valid again.
rec.FormatString = parameterFormatString;
Assert.AreEqual(properties[0], rec.ToString());
}
}
}
}
示例3: ExternalUIRecordLogger
public static MessageResult ExternalUIRecordLogger(
InstallMessage messageType,
Record messageRecord,
MessageButtons buttons,
MessageIcon icon,
MessageDefaultButton defaultButton)
{
if (messageRecord != null)
{
if (messageRecord.FormatString.Length == 0 && messageRecord.FieldCount > 0)
{
messageRecord.FormatString = "1: [1] 2: [2] 3: [3] 4: [4] 5: [5]";
}
Console.WriteLine("{0}: {1}", messageType, messageRecord.ToString());
}
else
{
Console.WriteLine("{0}: (null)", messageType);
}
return MessageResult.None;
}
示例4: GetErrorMessage
/// <summary>
/// Gets a formatted Windows Installer error message in a specified language.
/// </summary>
/// <param name="errorRecord">Error record containing the error number in the first field, and
/// error-specific parameters in the other fields.</param>
/// <param name="culture">The locale for the message.</param>
/// <returns>The message string, or null if the error message or locale is not found.</returns>
/// <remarks><p>
/// Error numbers greater than 2000 refer to MSI "internal" errors, and are always
/// returned in English.
/// </p></remarks>
internal static string GetErrorMessage(Record errorRecord, CultureInfo culture)
{
if (errorRecord == null)
{
throw new ArgumentNullException("errorRecord");
}
int errorNumber;
if (errorRecord.FieldCount < 1 || (errorNumber = (int) errorRecord.GetInteger(1)) == 0)
{
throw new ArgumentOutOfRangeException("errorRecord");
}
string msg = Installer.GetErrorMessage(errorNumber, culture);
if (msg != null)
{
errorRecord.FormatString = msg;
msg = errorRecord.ToString((IFormatProvider)null);
}
return msg;
}
示例5: FormatRecord
internal string FormatRecord(Record record, string format)
{
if (record == null)
{
throw new ArgumentNullException("record");
}
return record.ToString(format, this);
}
示例6: Format
internal string Format(string format)
{
if (format == null)
{
throw new ArgumentNullException("format");
}
using (Record formatRec = new Record(0))
{
formatRec.FormatString = format;
return formatRec.ToString(this);
}
}
示例7: FormatRecord
/// <summary>
/// Returns a formatted string from record data.
/// </summary>
/// <param name="record">Record object containing a template and data to be formatted.
/// The template string must be set in field 0 followed by any referenced data parameters.</param>
/// <returns>A formatted string containing the record data</returns>
/// <exception cref="InvalidHandleException">the Record handle is invalid</exception>
/// <remarks><p>
/// Win32 MSI API:
/// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiformatrecord.asp">MsiFormatRecord</a>
/// </p></remarks>
public string FormatRecord(Record record)
{
if (record == null)
{
throw new ArgumentNullException("record");
}
return record.ToString(this);
}
示例8: UIRecordHandler
/// <summary>
/// Handler for external UI messages.
/// </summary>
/// <param name="messageType">The type of message.</param>
/// <param name="messageRecord">The message details.</param>
/// <param name="buttons">Buttons to show (unused).</param>
/// <param name="icon">The icon to show (unused).</param>
/// <param name="defaultButton">The default button (unused).</param>
/// <returns>How the message was handled.</returns>
public MessageResult UIRecordHandler(
InstallMessage messageType,
Record messageRecord,
MessageButtons buttons,
MessageIcon icon,
MessageDefaultButton defaultButton)
{
#if False
Console.WriteLine("Message type {0}: {1}", messageType.ToString(), this.session.FormatRecord(messageRecord));
#endif
if (!this.session.IsClosed && 1 <= messageRecord.FieldCount)
{
switch (messageType)
{
case InstallMessage.ActionStart:
// only try to interpret the messages if they're coming from WixRunImmediateUnitTests
string action = messageRecord.GetString(1);
this.runningTests = Constants.LuxCustomActionName == action;
return MessageResult.OK;
case InstallMessage.User:
if (this.runningTests)
{
string message = messageRecord.ToString();
int id = messageRecord.GetInteger(1);
if (Constants.TestIdMinimumSuccess <= id && Constants.TestIdMaximumSuccess >= id)
{
this.OnMessage(NitVerboses.TestPassed(message));
++this.passes;
}
else if (Constants.TestIdMinimumFailure <= id && Constants.TestIdMaximumFailure >= id)
{
this.OnMessage(NitErrors.TestFailed(message));
++this.failures;
}
}
return MessageResult.OK;
case InstallMessage.Error:
case InstallMessage.FatalExit:
this.OnMessage(NitErrors.PackageFailed(this.session.FormatRecord(messageRecord)));
return MessageResult.Error;
}
}
return MessageResult.OK;
}
示例9: TestToString
public void TestToString()
{
string defaultString = "1: ";
string vegetaShout = "It's OVER 9000!!";
string gokuPowerLevel = "9001";
string nappaInquiry = "Vegeta, what's the Scouter say about his power level?";
string parameterFormatString = "[1]";
Record rec = new Record(1);
Assert.AreEqual(defaultString, rec.ToString(), "Testing default FormatString");
rec.FormatString = String.Empty;
Assert.AreEqual(defaultString, rec.ToString(), "Explicitly set the FormatString to the empty string.");
rec.FormatString = vegetaShout;
Assert.AreEqual(vegetaShout, rec.ToString(), "Testing text only (empty FormatString)");
rec.FormatString = gokuPowerLevel;
Assert.AreEqual(gokuPowerLevel, rec.ToString(), "Testing numbers only from a record that wasn't fetched.");
Record rec2 = new Record(nappaInquiry);
rec2.FormatString = parameterFormatString;
Assert.AreEqual(nappaInquiry, rec2.ToString(), "Testing text with a FormatString set.");
}