2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / nunit24 / NUnitCore / core / ExtensionPoint.cs
blob786d849d0a1526de8723c21322c2437871927f44
1 using System;
2 using System.Collections;
3 using NUnit.Core.Extensibility;
5 namespace NUnit.Core
7 /// <summary>
8 /// ExtensionPoint is used as a base class for all
9 /// extension points.
10 /// </summary>
11 public abstract class ExtensionPoint : IExtensionPoint
13 private string name;
14 private IExtensionHost host;
16 protected ArrayList extensions = new ArrayList();
18 #region Constructor
19 public ExtensionPoint(string name, IExtensionHost host)
21 this.name = name;
22 this.host = host;
24 #endregion
26 #region IExtensionPoint Members
27 /// <summary>
28 /// Get the name of this extension point
29 /// </summary>
30 public string Name
32 get { return this.name; }
35 /// <summary>
36 /// Get the host that provides this extension point
37 /// </summary>
38 public IExtensionHost Host
40 get { return this.host; }
43 /// <summary>
44 /// Install an extension at this extension point. If the
45 /// extension object does not meet the requirements for
46 /// this extension point, an exception is thrown.
47 /// </summary>
48 /// <param name="extension">The extension to install</param>
49 public void Install(object extension)
51 if ( !ValidExtension( extension ) )
52 throw new ArgumentException(
53 extension.GetType().FullName + " is not {0} extension point", "extension" );
55 extensions.Add( extension );
58 /// <summary>
59 /// Removes an extension from this extension point. If the
60 /// extension object is not present, the method returns
61 /// without error.
62 /// </summary>
63 /// <param name="extension"></param>
64 public void Remove(object extension)
66 extensions.Remove( extension );
68 #endregion
70 #region Abstract Methods
71 protected abstract bool ValidExtension(object extension);
72 #endregion