protected override void Dispose(bool disposing)
{
// Unadvise solution listeners.
try
{
if(disposing)
{
// only decrement the reference count once, regardless of the number of times Dispose is called.
// Ignore if Initialize was never called.
if (_initialized && !_disposed && Interlocked.Decrement(ref _singleFileGeneratorNodeExtenderReferenceCount) == 0)
{
ObjectExtenders objectExtenders = (ObjectExtenders)GetService(typeof(ObjectExtenders));
objectExtenders.UnregisterExtenderProvider(_singleFileGeneratorNodeExtenderCookie);
}
foreach(SolutionListener solutionListener in this.solutionListeners)
{
solutionListener.Dispose();
}
}
}
finally
{
_disposed = true;
base.Dispose(disposing);
}
}