aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Logging/EmbeddedLogItem.cs
blob: 607472e82a989d5ac7f76a32dc2031801e67cdf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Logging;
using Tango.PMR.Debugging;

namespace Tango.Integration.Logging
{
    public class EmbeddedLogItem : MessageLogItem
    {
        /// <summary>
        /// Gets or sets the debug log response.
        /// </summary>
        public StartDebugLogResponse DebugLogResponse { get; set; }

        private int _repeated;
        /// <summary>
        /// Gets or sets the number of times this message has been received continuously.
        /// </summary>
        public int Repeated
        {
            get { return _repeated; }
            set { _repeated = value; RaisePropertyChanged(nameof(Repeated)); RaisePropertyChanged(nameof(MessagePlusRepeated)); }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="EmbeddedLogItem"/> class.
        /// </summary>
        /// <param name="debugLogResponse">The debug log response.</param>
        public EmbeddedLogItem(StartDebugLogResponse debugLogResponse)
        {
            Repeated = 1;
            DebugLogResponse = debugLogResponse;
            Category = (LogCategory)debugLogResponse.Category;
            Message = debugLogResponse.Message;
            CallerFile = debugLogResponse.FileName;
            CallerLineNumber = (int)debugLogResponse.LineNumber;
        }

        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return String.Format("[{0}] [{1}] [{2}] [{3}] [{4}] [{5}]: {6}", TimeStamp.ToString("HH:mm:ss.ff"), DebugLogResponse.Category, Path.GetFileName(DebugLogResponse.FileName), DebugLogResponse.LineNumber, DebugLogResponse.ModuleId, DebugLogResponse.Filter, DebugLogResponse.Message);
        }

        /// <summary>
        /// Gets the message plus repeated.
        /// </summary>
        public String MessagePlusRepeated
        {
            get { return Repeated > 1 ? String.Format("{0} ({1})", Message, Repeated) : Message; }
        }

        /// <summary>
        /// Gets the relative caller file path.
        /// </summary>
        /// <returns></returns>
        protected override string GetRelativeCallerFilePath()
        {
            return CallerFile;
        }
    }
}
"w"> = this; HeightTreeNode oldNode; do { oldNode = node; node = node.parent; // go up until we are coming out of a left subtree } while (node != null && node.right == oldNode); return node; } } } /// <summary> /// The number of lines in this node and its child nodes. /// Invariant: /// totalCount = 1 + left.totalCount + right.totalCount /// </summary> internal int totalCount; /// <summary> /// The total height of this node and its child nodes, excluding directly collapsed nodes. /// Invariant: /// totalHeight = left.IsDirectlyCollapsed ? 0 : left.totalHeight /// + lineNode.IsDirectlyCollapsed ? 0 : lineNode.Height /// + right.IsDirectlyCollapsed ? 0 : right.totalHeight /// </summary> internal double totalHeight; /// <summary> /// List of the sections that hold this node collapsed. /// Invariant 1: /// For each document line in the range described by a CollapsedSection, exactly one ancestor /// contains that CollapsedSection. /// Invariant 2: /// A CollapsedSection is contained either in left+middle or middle+right or just middle. /// Invariant 3: /// Start and end of a CollapsedSection always contain the collapsedSection in their /// documentLine (middle node). /// </summary> internal List<CollapsedLineSection> collapsedSections; internal bool IsDirectlyCollapsed { get { return collapsedSections != null; } } internal void AddDirectlyCollapsed(CollapsedLineSection section) { if (collapsedSections == null) { collapsedSections = new List<CollapsedLineSection>(); totalHeight = 0; } Debug.Assert(!collapsedSections.Contains(section)); collapsedSections.Add(section); } internal void RemoveDirectlyCollapsed(CollapsedLineSection section) { Debug.Assert(collapsedSections.Contains(section)); collapsedSections.Remove(section); if (collapsedSections.Count == 0) { collapsedSections = null; totalHeight = lineNode.TotalHeight; if (left != null) totalHeight += left.totalHeight; if (right != null) totalHeight += right.totalHeight; } } #if DEBUG public override string ToString() { return "[HeightTreeNode " + documentLine.LineNumber + " CS=" + GetCollapsedSections(collapsedSections) + " Line.CS=" + GetCollapsedSections(lineNode.collapsedSections) + " Line.Height=" + lineNode.height + " TotalHeight=" + totalHeight + "]"; } static string GetCollapsedSections(List<CollapsedLineSection> list) { if (list == null) return "{}"; return "{" + string.Join(",", list.ConvertAll(cs=>cs.ID).ToArray()) + "}"; } #endif } }