|
#region Comments
/*
* Date Initials Comments
* 2013-07-17 Kishan Retrieve the configuration section for Email provider.
*/
#endregion Comments
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web.Configuration;
namespace Provider.EmailSender
{
public class EmailProviderManager
{
private static EmailProviderCollection m_providers;
private EmailProvider _MyEmailProvider;
public EmailProvider MyEmailProvider
{
get { return _MyEmailProvider; }
set { _MyEmailProvider = value; }
}
public EmailProviderCollection Providers
{
get { return m_providers; }
}
public void InitializeProvider()
{
EmailProviderConfiguration ObjConfiguration = default(EmailProviderConfiguration);
string sConfigEntry = string.Empty;
//This will be Web.config settings name
sConfigEntry = "EmailSend";
ObjConfiguration = (EmailProviderConfiguration)ConfigurationManager.GetSection(sConfigEntry);
if ((ObjConfiguration != null))
{
m_providers = new EmailProviderCollection();
ProvidersHelper.InstantiateProviders(ObjConfiguration.Providers, m_providers, typeof(EmailProvider));
m_providers.SetReadOnly();
//Set default provider.
MyEmailProvider = m_providers[ObjConfiguration.Default];
if (MyEmailProvider == null)
{
throw new Exception("Currently this Provider is not available.");
}
}
else
{
throw new ConfigurationErrorsException("This Email Provider configuration section is not set correctly.");
}
}
}
}
|
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.