CSharpTest.Net
ToXml Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : ToXml Method

Glossary Item Box

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
C# 
public string ToXml()

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.NETCopy 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

Generated with Document! X 2011 by Innovasys