Click here to Skip to main content
15,893,668 members
Articles / Web Development / HTML

Catch All Bugs with BugTrap!

Rate me:
Please Sign up or sign in to vote.
4.34/5 (84 votes)
31 Jan 2009MIT5 min read 1.9M   9.1K   293  
A tool that can catch unhandled errors and exceptions, and deliver error reports to remote support servers
/*
 * This is a part of the BugTrap package.
 * Copyright (c) 2005-2007 IntelleSoft.
 * All rights reserved.
 *
 * Description: SMTP state class.
 * Author: Maksim Pyatkovskiy.
 *
 * This source code is only intended as a supplement to the
 * BugTrap package reference and related electronic documentation
 * provided with the product. See these sources for detailed
 * information regarding the BugTrap package.
 */

using System;
using System.Net.Mail;

namespace BugTrapServer
{
	/// <summary>
	/// SMTP state object.
	/// </summary>
	internal class SmtpState : IDisposable
	{
		/// <summary>
		/// Initialize the object.
		/// </summary>
		/// <param name="client">STMP client.</param>
		/// <param name="message">Mail message.</param>
		public SmtpState(SmtpClient client, MailMessage message)
		{
			this.client = client;
			this.message = message;
		}

		/// <summary>
		/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
		/// </summary>
		public void Dispose()
		{
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}

		/// <summary>
		/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
		/// </summary>
		/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
		protected void Dispose(bool disposing)
		{
			if (!this.disposed)
			{
				if (disposing)
					this.message.Dispose();
				this.disposed = true;
			}
		}

		/// <summary>
		/// Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
		/// </summary>
		~SmtpState()
		{
			this.Dispose(false);
		}

		/// <summary>
		/// Get SMTP client.
		/// </summary>
		public SmtpClient Client
		{
			get { return this.client; }
		}

		/// <summary>
		/// Get mail message.
		/// </summary>
		public MailMessage Message
		{
			get { return this.message; }
		}

		/// <summary>
		/// SMTP client.
		/// </summary>
		private SmtpClient client;

		/// <summary>
		/// Mail message.
		/// </summary>
		private MailMessage message;

		/// <summary>
		/// True if object has been disposed.
		/// </summary>
		private bool disposed;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions