Esempio n. 1
0
        public string Serialize(TraceResult value)
        {
            if (value == null)
            {
                return(string.Empty);
            }
            try
            {
                TraceResultSerialized serializedResult = TraceResultHelper.GetReadyToSerializeVersion(value);


                var xmlserializer = new XmlSerializer(typeof(TraceResultSerialized));
                var stringWriter  = new StringWriter();
                using (var writer = XmlWriter.Create(stringWriter, new XmlWriterSettings()
                {
                    Indent = true, IndentChars = "\t"
                }))
                {
                    xmlserializer.Serialize(writer, serializedResult);
                    return(stringWriter.ToString());
                }
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred", ex);
            }
        }
Esempio n. 2
0
        public static TraceResultSerialized GetReadyToSerializeVersion(TraceResult value)
        {
            var result = new TraceResultSerialized();

            result.threads = new List <TraceResultInnerSerialized>();

            foreach (var item in value.TracedResult)
            {
                result.threads.Add(new TraceResultInnerSerialized()
                {
                    ExecutionTime = item.Value.Sum(x => x.ExecutionTime),
                    Methods       = item.Value,
                    ThreadId      = item.Key
                });
            }

            return(result);
        }