Skip to content
Permalink
Browse files
Add IDisposable interface to IDestination.
  • Loading branch information
Jim Gomes committed Mar 12, 2014
1 parent 0ffe98b commit 8ac613322351c2ed85bc74656506536f283698c4
Showing 2 changed files with 45 additions and 8 deletions.
@@ -26,23 +26,18 @@ public enum DestinationType
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; }
}

}


@@ -49,6 +49,8 @@ public abstract class Destination : IDestination, ICloneable
private String physicalName = "";
private StringDictionary options = null;

private bool disposed = false;

/// <summary>
/// The Default Constructor
/// </summary>
@@ -65,7 +67,47 @@ protected Destination(String name)
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
{

0 comments on commit 8ac6133

Please sign in to comment.