in src/StructuredLogger/Serialization/XlinqLogReader.cs [101:193]
private void ReadAttributes(BaseNode node, XElement element)
{
var item = node as Item;
if (item != null)
{
item.Name = GetString(element, AttributeNames.Name);
item.Text = GetString(element, AttributeNames.Text);
return;
}
var message = node as Message;
if (message != null)
{
message.IsLowRelevance = GetBoolean(element, AttributeNames.IsLowRelevance);
message.Timestamp = GetDateTime(element, AttributeNames.Timestamp);
message.Text = ReadTextContent(element);
return;
}
var folder = node as Folder;
if (folder != null)
{
folder.IsLowRelevance = GetBoolean(element, AttributeNames.IsLowRelevance);
return;
}
// then, shared "fall-through" tests that are common to many types of nodes
var namedNode = node as NamedNode;
if (namedNode != null)
{
namedNode.Name = GetString(element, AttributeNames.Name);
}
var textNode = node as TextNode;
if (textNode != null)
{
textNode.Text = GetString(element, AttributeNames.Text);
}
var timedNode = node as TimedNode;
if (timedNode != null)
{
AddStartAndEndTime(element, timedNode);
timedNode.NodeId = GetInteger(element, AttributeNames.NodeId);
}
// finally, concrete tests with early exit, sorted by commonality
var diagnostic = node as AbstractDiagnostic;
if (diagnostic != null)
{
diagnostic.Code = GetString(element, AttributeNames.Code);
diagnostic.File = GetString(element, AttributeNames.File);
diagnostic.LineNumber = GetInteger(element, AttributeNames.LineNumber);
diagnostic.ColumnNumber = GetInteger(element, AttributeNames.ColumnNumber);
diagnostic.EndLineNumber = GetInteger(element, AttributeNames.EndLineNumber);
diagnostic.EndColumnNumber = GetInteger(element, AttributeNames.EndColumnNumber);
diagnostic.ProjectFile = GetString(element, AttributeNames.ProjectFile);
return;
}
var task = node as Task;
if (task != null)
{
task.FromAssembly = GetString(element, AttributeNames.FromAssembly);
task.CommandLineArguments = GetString(element, AttributeNames.CommandLineArguments);
task.SourceFilePath = GetString(element, AttributeNames.File);
return;
}
var target = node as Target;
if (target != null)
{
target.IsLowRelevance = GetBoolean(element, AttributeNames.IsLowRelevance);
target.DependsOnTargets = GetString(element, AttributeNames.DependsOnTargets);
target.SourceFilePath = GetString(element, AttributeNames.File);
return;
}
var project = node as Project;
if (project != null)
{
project.ProjectFile = GetString(element, AttributeNames.ProjectFile);
return;
}
var build = node as Build;
if (build != null)
{
build.Succeeded = GetBoolean(element, AttributeNames.Succeeded);
build.IsAnalyzed = GetBoolean(element, AttributeNames.IsAnalyzed);
return;
}
}