1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[KOE-103] Improvements to tracing: added property logging and explicit gc to item events log.

This commit is contained in:
Patrick Simpson 2017-07-31 11:27:08 +03:00
parent d8b09c1d9d
commit e05768a399
4 changed files with 188 additions and 24 deletions

View File

@ -36,6 +36,7 @@
System.Windows.Forms.ColumnHeader columnCount; System.Windows.Forms.ColumnHeader columnCount;
System.Windows.Forms.ColumnHeader columnId; System.Windows.Forms.ColumnHeader columnId;
System.Windows.Forms.ColumnHeader columnEvents; System.Windows.Forms.ColumnHeader columnEvents;
System.Windows.Forms.ColumnHeader columnSubject;
this.tableMain = new System.Windows.Forms.TableLayoutPanel(); this.tableMain = new System.Windows.Forms.TableLayoutPanel();
this.flowButtons = new System.Windows.Forms.FlowLayoutPanel(); this.flowButtons = new System.Windows.Forms.FlowLayoutPanel();
this.buttonGC = new System.Windows.Forms.Button(); this.buttonGC = new System.Windows.Forms.Button();
@ -59,6 +60,9 @@
this._layoutItemEvents = new System.Windows.Forms.TableLayoutPanel(); this._layoutItemEvents = new System.Windows.Forms.TableLayoutPanel();
this.listItemEventDetails = new System.Windows.Forms.ListView(); this.listItemEventDetails = new System.Windows.Forms.ListView();
this.listItemEvents = new System.Windows.Forms.ListView(); this.listItemEvents = new System.Windows.Forms.ListView();
this._layoutEventsButtons = new System.Windows.Forms.FlowLayoutPanel();
this.buttonCleanGC = new System.Windows.Forms.Button();
this.columnProperties = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnMethod = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); columnMethod = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnFile = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); columnFile = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnLine = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); columnLine = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@ -66,6 +70,7 @@
columnCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); columnCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnId = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); columnId = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnEvents = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); columnEvents = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnSubject = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tableMain.SuspendLayout(); this.tableMain.SuspendLayout();
this.flowButtons.SuspendLayout(); this.flowButtons.SuspendLayout();
this._tabs.SuspendLayout(); this._tabs.SuspendLayout();
@ -75,6 +80,7 @@
this._layoutLocations.SuspendLayout(); this._layoutLocations.SuspendLayout();
this._tabItemEvents.SuspendLayout(); this._tabItemEvents.SuspendLayout();
this._layoutItemEvents.SuspendLayout(); this._layoutItemEvents.SuspendLayout();
this._layoutEventsButtons.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// columnMethod // columnMethod
@ -101,6 +107,14 @@
// //
resources.ApplyResources(columnId, "columnId"); resources.ApplyResources(columnId, "columnId");
// //
// columnEvents
//
resources.ApplyResources(columnEvents, "columnEvents");
//
// columnSubject
//
resources.ApplyResources(columnSubject, "columnSubject");
//
// tableMain // tableMain
// //
resources.ApplyResources(this.tableMain, "tableMain"); resources.ApplyResources(this.tableMain, "tableMain");
@ -262,13 +276,15 @@
resources.ApplyResources(this._layoutItemEvents, "_layoutItemEvents"); resources.ApplyResources(this._layoutItemEvents, "_layoutItemEvents");
this._layoutItemEvents.Controls.Add(this.listItemEventDetails, 0, 1); this._layoutItemEvents.Controls.Add(this.listItemEventDetails, 0, 1);
this._layoutItemEvents.Controls.Add(this.listItemEvents, 0, 0); this._layoutItemEvents.Controls.Add(this.listItemEvents, 0, 0);
this._layoutItemEvents.Controls.Add(this._layoutEventsButtons, 0, 2);
this._layoutItemEvents.Name = "_layoutItemEvents"; this._layoutItemEvents.Name = "_layoutItemEvents";
// //
// listItemEventDetails // listItemEventDetails
// //
this.listItemEventDetails.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.listItemEventDetails.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
columnEvent, columnEvent,
columnCount}); columnCount,
this.columnProperties});
resources.ApplyResources(this.listItemEventDetails, "listItemEventDetails"); resources.ApplyResources(this.listItemEventDetails, "listItemEventDetails");
this.listItemEventDetails.FullRowSelect = true; this.listItemEventDetails.FullRowSelect = true;
this.listItemEventDetails.MultiSelect = false; this.listItemEventDetails.MultiSelect = false;
@ -281,7 +297,8 @@
// //
this.listItemEvents.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.listItemEvents.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
columnId, columnId,
columnEvents}); columnEvents,
columnSubject});
resources.ApplyResources(this.listItemEvents, "listItemEvents"); resources.ApplyResources(this.listItemEvents, "listItemEvents");
this.listItemEvents.FullRowSelect = true; this.listItemEvents.FullRowSelect = true;
this.listItemEvents.HideSelection = false; this.listItemEvents.HideSelection = false;
@ -293,9 +310,22 @@
this.listItemEvents.View = System.Windows.Forms.View.Details; this.listItemEvents.View = System.Windows.Forms.View.Details;
this.listItemEvents.SelectedIndexChanged += new System.EventHandler(this.listItemEvents_SelectedIndexChanged); this.listItemEvents.SelectedIndexChanged += new System.EventHandler(this.listItemEvents_SelectedIndexChanged);
// //
// columnEvents // _layoutEventsButtons
// //
resources.ApplyResources(columnEvents, "columnEvents"); resources.ApplyResources(this._layoutEventsButtons, "_layoutEventsButtons");
this._layoutEventsButtons.Controls.Add(this.buttonCleanGC);
this._layoutEventsButtons.Name = "_layoutEventsButtons";
//
// buttonCleanGC
//
resources.ApplyResources(this.buttonCleanGC, "buttonCleanGC");
this.buttonCleanGC.Name = "buttonCleanGC";
this.buttonCleanGC.UseVisualStyleBackColor = true;
this.buttonCleanGC.Click += new System.EventHandler(this.buttonCleanGC_Click);
//
// columnProperties
//
resources.ApplyResources(this.columnProperties, "columnProperties");
// //
// DebugDialog // DebugDialog
// //
@ -317,6 +347,9 @@
this._layoutLocations.ResumeLayout(false); this._layoutLocations.ResumeLayout(false);
this._tabItemEvents.ResumeLayout(false); this._tabItemEvents.ResumeLayout(false);
this._layoutItemEvents.ResumeLayout(false); this._layoutItemEvents.ResumeLayout(false);
this._layoutItemEvents.PerformLayout();
this._layoutEventsButtons.ResumeLayout(false);
this._layoutEventsButtons.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -347,5 +380,8 @@
private System.Windows.Forms.TableLayoutPanel _layoutItemEvents; private System.Windows.Forms.TableLayoutPanel _layoutItemEvents;
private System.Windows.Forms.ListView listItemEventDetails; private System.Windows.Forms.ListView listItemEventDetails;
private System.Windows.Forms.ListView listItemEvents; private System.Windows.Forms.ListView listItemEvents;
private System.Windows.Forms.FlowLayoutPanel _layoutEventsButtons;
private System.Windows.Forms.Button buttonCleanGC;
private System.Windows.Forms.ColumnHeader columnProperties;
} }
} }

View File

@ -158,6 +158,7 @@ namespace Acacia.Features.DebugSupport
ListViewItem item = new ListViewItem(events.Id); ListViewItem item = new ListViewItem(events.Id);
item.Tag = events; item.Tag = events;
item.SubItems.Add(string.Join(", ", events.GetEvents())); item.SubItems.Add(string.Join(", ", events.GetEvents()));
item.SubItems.Add(events.Subject);
listItemEvents.Items.Add(item); listItemEvents.Items.Add(item);
} }
@ -175,6 +176,10 @@ namespace Acacia.Features.DebugSupport
{ {
ListViewItem item = new ListViewItem(evt.ToString()); ListViewItem item = new ListViewItem(evt.ToString());
item.SubItems.Add(debug.GetEventCount(evt).ToString()); item.SubItems.Add(debug.GetEventCount(evt).ToString());
if (evt == MailEvents.DebugEvent.PropertyChange)
item.SubItems.Add(string.Join(", ", debug.Properties));
listItemEventDetails.Items.Add(item); listItemEventDetails.Items.Add(item);
} }
} }
@ -182,6 +187,12 @@ namespace Acacia.Features.DebugSupport
header.Width = -2; header.Width = -2;
} }
private void buttonCleanGC_Click(object sender, EventArgs e)
{
MailEvents.MailEventsDebugClean();
RefreshItemEvents();
}
#endregion #endregion
#region Cycling #region Cycling

View File

@ -166,6 +166,18 @@
<data name="columnId.Width" type="System.Int32, mscorlib"> <data name="columnId.Width" type="System.Int32, mscorlib">
<value>44</value> <value>44</value>
</data> </data>
<metadata name="columnEvents.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<data name="columnEvents.Text" xml:space="preserve">
<value>Events</value>
</data>
<metadata name="columnSubject.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<data name="columnSubject.Text" xml:space="preserve">
<value>Subject</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="tableMain.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="tableMain.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value> <value>Top, Bottom, Left, Right</value>
@ -576,14 +588,17 @@
<data name="_layoutItemEvents.ColumnCount" type="System.Int32, mscorlib"> <data name="_layoutItemEvents.ColumnCount" type="System.Int32, mscorlib">
<value>1</value> <value>1</value>
</data> </data>
<data name="columnProperties.Text" xml:space="preserve">
<value>Properties</value>
</data>
<data name="listItemEventDetails.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms"> <data name="listItemEventDetails.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value> <value>Fill</value>
</data> </data>
<data name="listItemEventDetails.Location" type="System.Drawing.Point, System.Drawing"> <data name="listItemEventDetails.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 328</value> <value>3, 305</value>
</data> </data>
<data name="listItemEventDetails.Size" type="System.Drawing.Size, System.Drawing"> <data name="listItemEventDetails.Size" type="System.Drawing.Size, System.Drawing">
<value>597, 320</value> <value>597, 296</value>
</data> </data>
<data name="listItemEventDetails.TabIndex" type="System.Int32, mscorlib"> <data name="listItemEventDetails.TabIndex" type="System.Int32, mscorlib">
<value>3</value> <value>3</value>
@ -600,12 +615,6 @@
<data name="&gt;&gt;listItemEventDetails.ZOrder" xml:space="preserve"> <data name="&gt;&gt;listItemEventDetails.ZOrder" xml:space="preserve">
<value>0</value> <value>0</value>
</data> </data>
<metadata name="columnEvents.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<data name="columnEvents.Text" xml:space="preserve">
<value>Events</value>
</data>
<data name="listItemEvents.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms"> <data name="listItemEvents.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value> <value>Fill</value>
</data> </data>
@ -613,7 +622,7 @@
<value>3, 3</value> <value>3, 3</value>
</data> </data>
<data name="listItemEvents.Size" type="System.Drawing.Size, System.Drawing"> <data name="listItemEvents.Size" type="System.Drawing.Size, System.Drawing">
<value>597, 319</value> <value>597, 296</value>
</data> </data>
<data name="listItemEvents.TabIndex" type="System.Int32, mscorlib"> <data name="listItemEvents.TabIndex" type="System.Int32, mscorlib">
<value>2</value> <value>2</value>
@ -630,6 +639,66 @@
<data name="&gt;&gt;listItemEvents.ZOrder" xml:space="preserve"> <data name="&gt;&gt;listItemEvents.ZOrder" xml:space="preserve">
<value>1</value> <value>1</value>
</data> </data>
<data name="_layoutEventsButtons.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="_layoutEventsButtons.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="buttonCleanGC.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="buttonCleanGC.Location" type="System.Drawing.Point, System.Drawing">
<value>465, 3</value>
</data>
<data name="buttonCleanGC.Size" type="System.Drawing.Size, System.Drawing">
<value>129, 35</value>
</data>
<data name="buttonCleanGC.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="buttonCleanGC.Text" xml:space="preserve">
<value>Remove GC</value>
</data>
<data name="&gt;&gt;buttonCleanGC.Name" xml:space="preserve">
<value>buttonCleanGC</value>
</data>
<data name="&gt;&gt;buttonCleanGC.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonCleanGC.Parent" xml:space="preserve">
<value>_layoutEventsButtons</value>
</data>
<data name="&gt;&gt;buttonCleanGC.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="_layoutEventsButtons.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_layoutEventsButtons.FlowDirection" type="System.Windows.Forms.FlowDirection, System.Windows.Forms">
<value>RightToLeft</value>
</data>
<data name="_layoutEventsButtons.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 607</value>
</data>
<data name="_layoutEventsButtons.Size" type="System.Drawing.Size, System.Drawing">
<value>597, 41</value>
</data>
<data name="_layoutEventsButtons.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="&gt;&gt;_layoutEventsButtons.Name" xml:space="preserve">
<value>_layoutEventsButtons</value>
</data>
<data name="&gt;&gt;_layoutEventsButtons.Type" xml:space="preserve">
<value>System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;_layoutEventsButtons.Parent" xml:space="preserve">
<value>_layoutItemEvents</value>
</data>
<data name="&gt;&gt;_layoutEventsButtons.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="_layoutItemEvents.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms"> <data name="_layoutItemEvents.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value> <value>Fill</value>
</data> </data>
@ -637,7 +706,7 @@
<value>3, 3</value> <value>3, 3</value>
</data> </data>
<data name="_layoutItemEvents.RowCount" type="System.Int32, mscorlib"> <data name="_layoutItemEvents.RowCount" type="System.Int32, mscorlib">
<value>2</value> <value>3</value>
</data> </data>
<data name="_layoutItemEvents.Size" type="System.Drawing.Size, System.Drawing"> <data name="_layoutItemEvents.Size" type="System.Drawing.Size, System.Drawing">
<value>603, 651</value> <value>603, 651</value>
@ -658,7 +727,7 @@
<value>0</value> <value>0</value>
</data> </data>
<data name="_layoutItemEvents.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms"> <data name="_layoutItemEvents.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="listItemEventDetails" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="listItemEvents" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100,Absolute,20" /&gt;&lt;Rows Styles="Percent,50,Percent,50" /&gt;&lt;/TableLayoutSettings&gt;</value> <value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="listItemEventDetails" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="listItemEvents" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_layoutEventsButtons" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="Percent,50,Percent,50,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data> </data>
<data name="_tabItemEvents.Location" type="System.Drawing.Point, System.Drawing"> <data name="_tabItemEvents.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 33</value> <value>4, 33</value>
@ -798,6 +867,18 @@
<data name="&gt;&gt;columnId.Type" xml:space="preserve"> <data name="&gt;&gt;columnId.Type" xml:space="preserve">
<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;columnEvents.Name" xml:space="preserve">
<value>columnEvents</value>
</data>
<data name="&gt;&gt;columnEvents.Type" xml:space="preserve">
<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;columnSubject.Name" xml:space="preserve">
<value>columnSubject</value>
</data>
<data name="&gt;&gt;columnSubject.Type" xml:space="preserve">
<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;columnHeader1.Name" xml:space="preserve"> <data name="&gt;&gt;columnHeader1.Name" xml:space="preserve">
<value>columnHeader1</value> <value>columnHeader1</value>
</data> </data>
@ -822,10 +903,10 @@
<data name="&gt;&gt;columnHeader4.Type" xml:space="preserve"> <data name="&gt;&gt;columnHeader4.Type" xml:space="preserve">
<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;columnEvents.Name" xml:space="preserve"> <data name="&gt;&gt;columnProperties.Name" xml:space="preserve">
<value>columnEvents</value> <value>columnProperties</value>
</data> </data>
<data name="&gt;&gt;columnEvents.Type" xml:space="preserve"> <data name="&gt;&gt;columnProperties.Type" xml:space="preserve">
<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;$this.Name" xml:space="preserve"> <data name="&gt;&gt;$this.Name" xml:space="preserve">

View File

@ -1,4 +1,4 @@
/// Copyright 2016 Kopano b.v. /// Copyright 2017 Kopano b.v.
/// ///
/// This program is free software: you can redistribute it and/or modify /// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3, /// it under the terms of the GNU Affero General Public License, version 3,
@ -380,8 +380,10 @@ namespace Acacia.Utils
public interface MailEventDebug public interface MailEventDebug
{ {
string Id { get; } string Id { get; }
string Subject { get; }
int GetEventCount(DebugEvent which); int GetEventCount(DebugEvent which);
IEnumerable<DebugEvent> GetEvents(); IEnumerable<DebugEvent> GetEvents();
IEnumerable<string> Properties { get; }
} }
public static IEnumerable<MailEventDebug> MailEventsDebug public static IEnumerable<MailEventDebug> MailEventsDebug
@ -389,6 +391,18 @@ namespace Acacia.Utils
get { return _hookers?.Values; } get { return _hookers?.Values; }
} }
public static void MailEventsDebugClean()
{
foreach (MailEventDebugImpl impl in _hookers.Values)
{
if (impl.GetEventCount(DebugEvent.GC) > 0)
{
MailEventDebugImpl dummy;
_hookers.TryRemove(impl._id, out dummy);
}
}
}
private static readonly ConcurrentDictionary<int, MailEventDebugImpl> _hookers = private static readonly ConcurrentDictionary<int, MailEventDebugImpl> _hookers =
GlobalOptions.INSTANCE.WrapperTrace ? new ConcurrentDictionary<int, MailEventDebugImpl>() : null; GlobalOptions.INSTANCE.WrapperTrace ? new ConcurrentDictionary<int, MailEventDebugImpl>() : null;
private static int _nextHookerId; private static int _nextHookerId;
@ -423,14 +437,13 @@ namespace Acacia.Utils
if (_debug != null) if (_debug != null)
{ {
_debug.RecordEvent(DebugEvent.Dispose); _debug.RecordEvent(DebugEvent.Dispose);
MailEventDebugImpl dummy;
_hookers.TryRemove(_debug._id, out dummy);
} }
} }
~MailEventHooker() ~MailEventHooker()
{ {
_debug?.RecordEvent(DebugEvent.GC); _debug?.RecordEvent(DebugEvent.GC);
_debug?.Finished();
} }
private void HookEvents(bool add) private void HookEvents(bool add)
@ -478,13 +491,17 @@ namespace Acacia.Utils
private void HandlePropertyChange(string name) private void HandlePropertyChange(string name)
{ {
_debug?.RecordEvent(DebugEvent.PropertyChange); _debug?.RecordEvent(DebugEvent.PropertyChange, name);
_events.OnPropertyChange(_item, name); _events.OnPropertyChange(_item, name);
} }
private void HandleRead() private void HandleRead()
{ {
_debug?.RecordEvent(DebugEvent.Read); if (_debug != null)
{
_debug.RecordEvent(DebugEvent.Read);
_debug.Subject = _item.Subject;
}
// TODO: should this not be simply an IItem? // TODO: should this not be simply an IItem?
_events.OnRead(_item as IMailItem); _events.OnRead(_item as IMailItem);
} }
@ -521,8 +538,14 @@ namespace Acacia.Utils
private class MailEventDebugImpl : MailEventDebug private class MailEventDebugImpl : MailEventDebug
{ {
private readonly ConcurrentDictionary<DebugEvent, int> _eventCounts = new ConcurrentDictionary<DebugEvent, int>(); private readonly ConcurrentDictionary<DebugEvent, int> _eventCounts = new ConcurrentDictionary<DebugEvent, int>();
private readonly List<string> _properties = new List<string>();
public readonly int _id; public readonly int _id;
public DateTime? GCTime
{
get;
private set;
}
public MailEventDebugImpl(int id) public MailEventDebugImpl(int id)
{ {
@ -536,9 +559,11 @@ namespace Acacia.Utils
return count; return count;
} }
public void RecordEvent(DebugEvent which) public void RecordEvent(DebugEvent which, string property = null)
{ {
_eventCounts.AddOrUpdate(which, 1, (i, value) => value + 1); _eventCounts.AddOrUpdate(which, 1, (i, value) => value + 1);
if (property != null)
_properties.Add(property);
} }
public IEnumerable<DebugEvent> GetEvents() public IEnumerable<DebugEvent> GetEvents()
@ -546,7 +571,18 @@ namespace Acacia.Utils
return _eventCounts.Keys; return _eventCounts.Keys;
} }
public IEnumerable<string> Properties
{
get { return _properties; }
}
public void Finished()
{
GCTime = DateTime.Now;
}
public string Id { get { return _id.ToString(); } } public string Id { get { return _id.ToString(); } }
public string Subject { get; set; }
} }
#endregion #endregion