I have a factory class that keeps an instance of a CrystalReports.Engine.ReportDocument
. I'm implementing IDisposable per an awesome SO post, but not sure if the resource is managed or unmanaged.
I'm assuming it's managed since a .NET library, and doing it like this:
using CrystalDecisions.CrystalReports.Engine;
public class ReportFactory: IDisposable {
public ReportDocument Report { get; private set; }
private bool IsDisposed { get; set; }
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool freeManagedReousrces) {
try {
if (IsDisposed) return;
if ((freeManagedReousrces)) {
// Release managed resources.
if (Report != null) {
Report.Dispose();
}
}
// Release un-managed resources.
// None
}
finally {
IsDisposed = true;
}
}
// No finalizer needed: no unmanaged resources.
}
Please verify that the ReportDocument is a managed resource and that I'm handling it properly.