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

Backup commit, not compiling at the moment

This commit is contained in:
Patrick Simpson 2017-02-14 18:30:48 +01:00
parent dc12b73bbc
commit 026f537dae
2 changed files with 13 additions and 3 deletions

View File

@ -10,6 +10,8 @@ namespace Acacia.Utils
{ {
abstract public class DisposableWrapper : IDisposable abstract public class DisposableWrapper : IDisposable
{ {
private static Dictionary<Type, int> typeCounts = new Dictionary<Type, int>();
protected DisposableWrapper() protected DisposableWrapper()
{ {
Interlocked.Increment(ref Statistics.CreatedWrappers); Interlocked.Increment(ref Statistics.CreatedWrappers);
@ -25,6 +27,10 @@ namespace Acacia.Utils
// Dispose, but don't count auto disposals, so the stats show it. // Dispose, but don't count auto disposals, so the stats show it.
DoRelease(); DoRelease();
} }
else
{
--typeCounts[GetType()];
}
} }
private bool _isDisposed; private bool _isDisposed;
@ -34,6 +40,11 @@ namespace Acacia.Utils
{ {
if (!_isDisposed) if (!_isDisposed)
{ {
if (!typeCounts.ContainsKey(GetType()))
typeCounts.Add(GetType(), 1);
else
++typeCounts[GetType()];
Logger.Instance.TraceExtra(this, "Disposing wrapper: {0}", new System.Diagnostics.StackTrace()); Logger.Instance.TraceExtra(this, "Disposing wrapper: {0}", new System.Diagnostics.StackTrace());
_isDisposed = true; _isDisposed = true;
Interlocked.Increment(ref Statistics.DisposedWrappers); Interlocked.Increment(ref Statistics.DisposedWrappers);

View File

@ -141,7 +141,7 @@ namespace Acacia.ZPush
try try
{ {
Logger.Instance.Debug(this, "Folder added in {0}: {1}", Name, folder.Name); Logger.Instance.Debug(this, "Folder added in {0}: {1}", Name, folder.Name);
WatchChild(folder); WatchChild(folder.Duplicate());
} }
catch (System.Exception e) { Logger.Instance.Error(this, "Exception in SubFolders_FolderAdd: {0}: {1}", Name, e); } catch (System.Exception e) { Logger.Instance.Error(this, "Exception in SubFolders_FolderAdd: {0}: {1}", Name, e); }
} }
@ -198,7 +198,6 @@ namespace Acacia.ZPush
if (_children.TryGetValue(folder.EntryID, out child)) if (_children.TryGetValue(folder.EntryID, out child))
{ {
_watcher.OnFolderChanged(child); _watcher.OnFolderChanged(child);
// TODO: release folder?
} }
else else
{ {
@ -206,7 +205,7 @@ namespace Acacia.ZPush
// Create it now // Create it now
// This will send a discover notification if required, which is just as good as a change notification // This will send a discover notification if required, which is just as good as a change notification
Logger.Instance.Debug(this, "Folder change on unreported folder in {0}: {1}, {2}, {3}", Name, folder.Name, folder.EntryID, folder.StoreDisplayName); Logger.Instance.Debug(this, "Folder change on unreported folder in {0}: {1}, {2}, {3}", Name, folder.Name, folder.EntryID, folder.StoreDisplayName);
WatchChild(folder); WatchChild(folder.Duplicate());
} }
} }
catch (System.Exception e) { Logger.Instance.Error(this, "Exception in SubFolders_FolderChange: {0}: {1}", Name, e); } catch (System.Exception e) { Logger.Instance.Error(this, "Exception in SubFolders_FolderChange: {0}: {1}", Name, e); }