using System.Collections.Generic;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO.Compression;
using System.Globalization;
public string ID { get; }
public List<LogPoint> LogPoints { get; } = new List<LogPoint>();
public LogData (string id)
public int Index { get; }
public double Value { get; }
public LogPoint ( int index, double value)
public static void Test()
var xmlFile = "singleVersusMultLine.xml";
File.WriteAllText(xmlFile, xml);
public static void Test(string xmlFile)
List<LogData> logDatas = GetLogDatasFromFile(xmlFile);
Console.WriteLine("Main");
Console.WriteLine("logData");
foreach (LogData logData in logDatas)
Console.WriteLine($" logData.ID {logData.ID}");
foreach(LogPoint logPoint in logData.LogPoints)
Console.WriteLine($" logData.Index {logPoint.Index} logData.Value {logPoint.Value}");
Console.WriteLine("end");
var xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<data><index>100</index><value>150</value></data>
<data><index>110</index><value>750</value></data>
<data><index>120</index><value>750</value></data>
<data><index>130</index><value>150</value></data>
<data><index>140</index><value>0</value></data>
<data><index>150</index><value>222</value></data>
public static List<LogData> GetLogDatasFromFile(string xmlFile)
List<LogData> logDatas = new List<LogData>();
using (XmlReader reader = XmlReader.Create(xmlFile))
while (reader.ReadToFollowing("logData", ""))
var logData = new LogData(reader.GetAttribute("id"));
using (var logDataReader = reader.ReadSubtree())
while (logDataReader.ReadToFollowing("data", ""))
logDataReader.ReadToFollowing("index", "");
var index = XmlConvert.ToInt32(logDataReader.ReadElementContentAsString());
logDataReader.ReadToFollowingOrCurrent("value", "");
var value = XmlConvert.ToDouble(logDataReader.ReadElementContentAsString());
logData.LogPoints.Add(new LogPoint(index, value));
public static class XmlReaderExtensions
public static bool ReadToFollowingOrCurrent(this XmlReader reader, string localName, string namespaceURI)
throw new ArgumentNullException(nameof(reader));
if (reader.NodeType == XmlNodeType.Element && reader.LocalName == localName && reader.NamespaceURI == namespaceURI)
return reader.ReadToFollowing(localName, namespaceURI);
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
public static void IsTrue(bool value, string message)
throw new AssertionFailedException(message ?? "failed");
public static void Main()
Console.WriteLine("Roslyn 2.0 Compiler; Environment version: " + Environment.Version);
Console.WriteLine("Uncaught exception: ");