Returns this data as an XmlWriter text fragment who name is the class name and each attribute is the field name, again maintaining the case.
Syntax
Visual Basic (Declaration) | |
---|
Public Function ToXml() As String |
Example
Log/Test/BasicLogTest.cs
C# | Copy Code |
---|
Log.Write("");
EventData msg = LastMessage;
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);
using (Log.Start(UniqueData))
{
msg = LastMessage;
Assert.AreEqual("Start " + UniqueData, msg.Message);
Assert.AreEqual(UniqueData, msg.LogCurrent);
Assert.AreEqual(msg.LogCurrent, msg.LogStack);
using (Log.Start("2ndlevel"))
{
msg = LastMessage;
Assert.AreEqual("Start 2ndlevel", msg.Message);
Assert.AreEqual("2ndlevel", msg.LogCurrent);
Assert.AreEqual(UniqueData + "::2ndlevel", msg.LogStack);
Assert.IsTrue(msg.ToXml().Contains("2ndlevel"));
Assert.AreEqual("2ndlevel", msg.ToString("{LogCurrent}"));
}
msg = LastMessage;
Assert.IsTrue(msg.Message.StartsWith("End 2ndlevel"));
Assert.AreEqual(UniqueData, msg.LogCurrent);
Assert.AreEqual(msg.LogCurrent, msg.LogStack);
}
msg = LastMessage;
Assert.IsTrue(msg.Message.StartsWith("End " + UniqueData));
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack); |
VB.NET | Copy Code |
---|
Log.Write("")
Dim msg As EventData = LastMessage
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)
Using Log.Start(UniqueData)
msg = LastMessage
Assert.AreEqual("Start " + UniqueData, msg.Message)
Assert.AreEqual(UniqueData, msg.LogCurrent)
Assert.AreEqual(msg.LogCurrent, msg.LogStack)
Using Log.Start("2ndlevel")
msg = LastMessage
Assert.AreEqual("Start 2ndlevel", msg.Message)
Assert.AreEqual("2ndlevel", msg.LogCurrent)
Assert.AreEqual(UniqueData + "::2ndlevel", msg.LogStack)
Assert.IsTrue(msg.ToXml().Contains("2ndlevel"))
Assert.AreEqual("2ndlevel", msg.ToString("{LogCurrent}"))
End Using
msg = LastMessage
Assert.IsTrue(msg.Message.StartsWith("End 2ndlevel"))
Assert.AreEqual(UniqueData, msg.LogCurrent)
Assert.AreEqual(msg.LogCurrent, msg.LogStack)
End Using
msg = LastMessage
Assert.IsTrue(msg.Message.StartsWith("End " + UniqueData))
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also