Click here to Skip to main content
15,896,207 members
Articles / Database Development / SQL Server

Ready-to-use Mass Emailing Functionality with C#, .NET 2.0, and Microsoft® SQL Server 2005 Service Broker

Rate me:
Please Sign up or sign in to vote.
4.84/5 (40 votes)
7 Sep 200613 min read 299K   4.6K   210  
This paper demonstrates an extensible mass emailing framework (Smart Mass Email SME). The demo implementation uses cutting edge .NET technologies available today such as C#, .NET 2.0, Microsoft® SQL Server 2005 Service Broker, MS Provider Pattern, Enterprise Library January 2006 etc.
using System;
using System.Text;

using System.Reflection;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;

namespace SmartMassEmail.Entities
{
	/// <summary>
	/// Provides a unified way of converting types of values to other types, as well as for accessing standard values and subproperties.
	/// Used by the nettiers strongly typed collection, so they can be saved in ViewState.
	/// </summary>
	public class GenericTypeConverter : TypeConverter
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="GenericTypeConverter"/> class.
		/// </summary>
		public GenericTypeConverter()
		{
		}
		
		/// <summary>
		/// Returns whether this converter can convert the object to the specified type.
		/// </summary>
		public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
		{
			if(destinationType == typeof(InstanceDescriptor))
				return true;
				
			return base.CanConvertTo(context,destinationType);
		}
		
		/// <summary>
		/// Converts the given value object to the specified type.
		/// </summary>
		public override object ConvertTo(ITypeDescriptorContext context,
		              System.Globalization.CultureInfo culture,
		              object val,Type destinationType)
		{
			if(destinationType == typeof(InstanceDescriptor))
			{
				Type valueType = val.GetType();
				ConstructorInfo ci = valueType.GetConstructor(System.Type.EmptyTypes);
				return new InstanceDescriptor(ci,null,false);
			}
			return base.ConvertTo(context,culture,val,destinationType);
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Australia Australia
I have been awarded MVP (Visual C#) for year 2007, 2008, 2009. I am a Microsoft Certified Application Developer (C# .Net). I currently live in Melbourne, Australia. I am a co-founder and core developer of Pageflakes www.pageflakes.com and Founder of Simplexhub, a highly experienced software development company based in Melbourne Australia and Dhaka, Bangladesh. Simplexhub.
My BLOG http://www.geekswithblogs.net/shahed
http://msmvps.com/blogs/shahed/Default.aspx.

Comments and Discussions