PageRenderTime 26ms CodeModel.GetById 23ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/NUnit/core/ExtensionHost.cs

#
C# | 54 lines | 34 code | 8 blank | 12 comment | 2 complexity | 46307f71b2eb3394c8232f66971ba029 MD5 | raw file
 1// ****************************************************************
 2// Copyright 2007, Charlie Poole
 3// This is free software licensed under the NUnit license. You may
 4// obtain a copy of the license at http://nunit.org.
 5// ****************************************************************
 6using System;
 7using System.Collections;
 8using NUnit.Core.Extensibility;
 9
10namespace NUnit.Core
11{
12	/// <summary>
13	/// ExtensionHost is the abstract base class used for
14	/// all extension hosts. It provides an array of 
15	/// extension points and a FrameworkRegistry and
16	/// implements the IExtensionHost interface. Derived
17	/// classes must initialize the extension points.
18	/// </summary>
19	public abstract class ExtensionHost : IExtensionHost
20	{
21		#region Protected Fields
22
23	    protected ArrayList extensions;
24
25		protected ExtensionType supportedTypes;
26		#endregion
27
28		#region IExtensionHost Interface
29		public IExtensionPoint[] ExtensionPoints
30		{
31			get { return (IExtensionPoint[])extensions.ToArray(typeof(IExtensionPoint)); }
32		}
33
34        public IFrameworkRegistry FrameworkRegistry
35        {
36            get { return (IFrameworkRegistry)GetExtensionPoint("FrameworkRegistry"); }
37        }
38
39		public IExtensionPoint GetExtensionPoint( string name )
40		{
41			foreach ( IExtensionPoint extensionPoint in extensions )
42				if ( extensionPoint.Name == name )
43					return extensionPoint;
44
45			return null;
46		}
47
48		public ExtensionType ExtensionTypes
49		{
50			get { return supportedTypes; }
51		}
52		#endregion
53	}
54}