Add IDisposable interface to IDestination.
Fixes [AMQNET-473]. (See https://issues.apache.org/jira/browse/AMQNET-473)
diff --git a/src/main/csharp/IDestination.cs b/src/main/csharp/IDestination.cs
index e5b7b71..7f960c4 100644
--- a/src/main/csharp/IDestination.cs
+++ b/src/main/csharp/IDestination.cs
@@ -26,23 +26,18 @@
TemporaryQueue,
TemporaryTopic
}
-
-
+
/// <summary>
/// A base interface for destinations such as queues or topics
/// </summary>
- public interface IDestination
+ public interface IDestination : System.IDisposable
{
-
DestinationType DestinationType { get; }
bool IsTopic { get; }
-
bool IsQueue { get; }
-
bool IsTemporary { get; }
}
-
}
diff --git a/src/test/csharp/Commands/Destination.cs b/src/test/csharp/Commands/Destination.cs
index 2eea455..58c7749 100755
--- a/src/test/csharp/Commands/Destination.cs
+++ b/src/test/csharp/Commands/Destination.cs
@@ -49,6 +49,8 @@
private String physicalName = "";
private StringDictionary options = null;
+ private bool disposed = false;
+
/// <summary>
/// The Default Constructor
/// </summary>
@@ -65,7 +67,47 @@
setPhysicalName(name);
}
- public bool IsTopic
+ ~Destination()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if(disposed)
+ {
+ return;
+ }
+
+ if(disposing)
+ {
+ try
+ {
+ OnDispose();
+ }
+ catch(Exception ex)
+ {
+ Tracer.ErrorFormat("Exception disposing Destination {0}: {1}", this.physicalName, ex.Message);
+ }
+ }
+
+ disposed = true;
+ }
+
+ /// <summary>
+ /// Child classes can override this method to perform clean-up logic.
+ /// </summary>
+ protected virtual void OnDispose()
+ {
+ }
+
+ public bool IsTopic
{
get
{