本文整理汇总了C#中LogEntry.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# LogEntry.Clone方法的具体用法?C# LogEntry.Clone怎么用?C# LogEntry.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogEntry
的用法示例。
在下文中一共展示了LogEntry.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogEntryCloneMethodTest
public void LogEntryCloneMethodTest()
{
LogEntry entry = new LogEntry();
entry.ActivityId = new Guid("AAAABBBBCCCCDDDDAAAABBBBCCCCDDDD");
entry.AddErrorMessage("LogEntryCloneMethodTest exception");
entry.Categories.Add("Error");
entry.EventId = 1;
entry.ExtendedProperties.Add("key1", "value1");
entry.Message = "To test the cloning method";
entry.Priority = 10;
entry.Severity = TraceEventType.Critical;
entry.Title = "LogEntryCloneMethodTest";
LogEntry clonedEntry = (LogEntry)entry.Clone();
Assert.AreEqual(entry.ActivityIdString, clonedEntry.ActivityIdString);
Assert.AreEqual(entry.Categories.Count, clonedEntry.Categories.Count);
Assert.AreEqual(entry.EventId, clonedEntry.EventId);
Assert.AreEqual(entry.ExtendedProperties.Count, clonedEntry.ExtendedProperties.Count);
Assert.AreEqual(entry.Message, clonedEntry.Message);
Assert.AreEqual(entry.Priority, clonedEntry.Priority);
Assert.AreEqual(entry.ProcessId, clonedEntry.ProcessId);
Assert.AreEqual(entry.ProcessName, clonedEntry.ProcessName);
Assert.AreEqual(entry.Severity, clonedEntry.Severity);
Assert.AreEqual(entry.TimeStamp, clonedEntry.TimeStamp);
Assert.AreEqual(entry.TimeStampString, clonedEntry.TimeStampString);
Assert.AreEqual(entry.Title, clonedEntry.Title);
Assert.AreEqual(entry.Win32ThreadId, clonedEntry.Win32ThreadId);
Assert.AreEqual(entry.ManagedThreadName, clonedEntry.ManagedThreadName);
Assert.AreEqual(entry.MachineName, clonedEntry.MachineName);
Assert.AreEqual(entry.ErrorMessages, clonedEntry.ErrorMessages);
Assert.AreEqual(entry.AppDomainName, clonedEntry.AppDomainName);
clonedEntry.Categories.Add("Debug");
clonedEntry.ExtendedProperties.Add("key2", "value2");
clonedEntry.ActivityId = new Guid("EEEEFFFFEEEEFFFFEEEEFFFFEEEEFFFF");
Assert.IsTrue(entry.Categories.Count == 1);
Assert.IsTrue(clonedEntry.Categories.Count == 2);
Assert.IsTrue(entry.ExtendedProperties.Count == 1);
Assert.IsTrue(clonedEntry.ExtendedProperties.Count == 2);
Assert.IsFalse(entry.ActivityIdString == clonedEntry.ActivityIdString);
}