Click here to Skip to main content
15,894,546 members
Articles / Programming Languages / C#

The Razor Framework :: Part 1 :: Plugins/Extensibility

Rate me:
Please Sign up or sign in to vote.
4.93/5 (127 votes)
11 Mar 2005CPOL36 min read 351.8K   1.4K   446  
An extensible dependency based plugin framework for .NET Applications.
using System;
using System.Diagnostics;
using System.Collections;

namespace Razor.Networking.AutoUpdate.Common
{
	/// <summary>
	/// Summary description for AutoUpdateDownloaderList.
	/// </summary>
	public class AutoUpdateDownloaderList : CollectionBase 
	{
		/// <summary>
		/// Initializes a new instance of the AutoUpdateDownloaderList class
		/// </summary>
		public AutoUpdateDownloaderList()
		{
			
		}

		public void Add(AutoUpdateDownloader downloader)
		{
			if (downloader ==  null)
				throw new ArgumentNullException("downloader");

			if (this.Contains(downloader))
				throw new AutoUpdateDownloaderAlreadyExistsException(downloader);

			base.InnerList.Add(downloader);
		}

		public void AddRange(AutoUpdateDownloader[] downloaders)
		{
			if (downloaders == null)
				throw new ArgumentNullException("downloaders");

			foreach(AutoUpdateDownloader downloader in downloaders)
				this.Add(downloader);
		}

		public void Remove(AutoUpdateDownloader downloader)
		{
			if (downloader ==  null)
				throw new ArgumentNullException("downloader");

			if (this.Contains(downloader))
				base.InnerList.Remove(downloader);
		}

		public bool Contains(AutoUpdateDownloader downloader)
		{
			if (downloader ==  null)
				throw new ArgumentNullException("downloader");

			foreach(AutoUpdateDownloader existingDownloader in base.InnerList)
				if (string.Compare(existingDownloader.Id, downloader.Id, true) == 0)
					return true;

			return false;
		}

		public AutoUpdateDownloader this[int index]
		{
			get
			{
				return base.InnerList[index] as AutoUpdateDownloader;
			}
		}

		public AutoUpdateDownloader this[string id]
		{
			get
			{
				foreach(AutoUpdateDownloader existingDownloader in base.InnerList)
					if (string.Compare(existingDownloader.Id, id, true) == 0)
						return existingDownloader;

				return null;
			}
		}
	}
}

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)


Written By
Software Developer (Senior)
United States United States
Senior Application Developer specializing in Windows desktop and network development.

Professional Experience
- B.S. of Computer Science (Graduated 2001 - PSU)
- Senior Application Developer (8+ yrs)
- Microsoft Certified Professional

Primary Interests
- C#, C++, HTML, Javascript
- XML, ASP.NET, Web Services, SOAP, UDDI
- Socket programming and anything network related
- Reflection, Serialization, and Plugin Frameworks
- Owner-drawn controls and GDI+ goodness

Comments and Discussions