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

Small cleanup to folder item iteration

This commit is contained in:
Patrick Simpson 2017-02-07 14:45:34 +01:00
parent b952f46ff9
commit ac56b301b4
2 changed files with 15 additions and 11 deletions

View File

@ -139,11 +139,7 @@ namespace Acacia.Stubs.OutlookWrappers
{
get
{
if (_last != null)
{
_last.Dispose();
_last = default(ItemType);
}
CleanLast();
_last = Mapping.Wrap<ItemType>(_enum.Current);
return _last;
}
@ -157,12 +153,23 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
private void CleanLast()
{
if (_last != null)
{
_last.Dispose();
_last = default(ItemType);
}
}
public void Dispose()
{
CleanLast();
if (_enum != null)
{
if (_enum is IDisposable)
((IDisposable)_enum).Dispose();
ComRelease.Release(_enum);
_enum = null;
}
if (_items != null)
@ -174,16 +181,13 @@ namespace Acacia.Stubs.OutlookWrappers
public bool MoveNext()
{
if (_last != null)
{
_last.Dispose();
_last = default(ItemType);
}
CleanLast();
return _enum.MoveNext();
}
public void Reset()
{
CleanLast();
_enum.Reset();
}
}

View File

@ -59,7 +59,7 @@ namespace Acacia.Utils
{
if (!Enabled)
return;
if (o == null)
if (o == null || !Marshal.IsComObject(o))
return;
if (Logger.Instance.IsLevelEnabled(LogLevel.TraceExtra))