Click here to Skip to main content
12,634,330 members (26,276 online)
Click here to Skip to main content

Stats

84.2K views
575 downloads
155 bookmarked
Posted

Learn How to Build a Provider Framework - With an Easy to Understand Example Towards Applying the Provider Pattern

, 20 Jul 2007 CPOL
After reading this article, you'll be able to: (1) Change your mindset a little bit, and start thinking about 'frameworks' instead of just 'code' (2) Understand a lot about practically applying the Provider pattern in your projects (3) Gain much knowledge regarding XML config files and providers.
Sumeru.Publisher
bin
Debug
Sumeru.Publisher.dll
obj
Debug
temp
TempPE
Publisher.xsx
Sumeru.Publisher.csproj.user
Sumeru.Publisher.FTPPublisher
bin
Debug
Sumeru.Publisher.dll
Sumeru.Publisher.FTPPublisher.dll
obj
Debug
temp
TempPE
Sumeru.Publisher.FTPPublisher.csproj.user
Sumeru.Publisher.Loader
App.ico
bin
Debug
Sumeru.Publisher.dll
Sumeru.Publisher.FTPPublisher.dll
Sumeru.Publisher.Loader.exe
obj
Debug
temp
TempPE
Sumeru.Publisher.Loader.csproj.user
using System;
using System.Reflection;

namespace Sumeru.Publisher.Framework
{
	/// <summary>
	/// Summary description for PublisherFactory.
	/// </summary>
	public abstract class PublisherFactory
	{
		private PublisherFactory()
		{
		}


		/// <summary>
		/// Creates the publisher and return a type of IPublisher
		/// </summary>
		/// <param name="assembly">The path to the assembly</param>
		/// <param name="className">The class name to instantiate</param>
		/// <param name="settings">The settings collection</param>
		/// <returns></returns>
		public static IPublisher CreatePublisher(string assemblyName, string className,  Sumeru.Publisher.Framework.Data.SettingCollection settings) 
		{

			try 
			{
				IPublisher ipub;
				
				Assembly asm=Assembly.LoadFrom(assemblyName); 
				System.Type type=asm.GetType(className);
				object pub=Activator.CreateInstance(type); 
				ipub=(IPublisher) pub;
				ipub.Init(settings);
				return ipub;
			}
			catch (Exception ex) 
			{
				throw ex;

			}

		}

	}
}

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 Code Project Open License (CPOL)

Share

About the Author


You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161208.2 | Last Updated 20 Jul 2007
Article Copyright 2007 by Anoop Madhusudanan
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid