Merge pull request #3142 from henricm/fix-for-win-mono_string_to_utf8
[mono.git] / mcs / nunit24 / NUnitCore / core / ExtensionPoint.cs
1 using System;\r
2 using System.Collections;\r
3 using NUnit.Core.Extensibility;\r
4 \r
5 namespace NUnit.Core\r
6 {\r
7         /// <summary>\r
8         /// ExtensionPoint is used as a base class for all \r
9         /// extension points.\r
10         /// </summary>\r
11         public abstract class ExtensionPoint : IExtensionPoint\r
12         {\r
13                 private string name;\r
14                 private IExtensionHost host;\r
15 \r
16                 protected ArrayList extensions = new ArrayList();\r
17 \r
18                 #region Constructor\r
19                 public ExtensionPoint(string name, IExtensionHost host)\r
20                 {\r
21                         this.name = name;\r
22                         this.host = host;\r
23                 }\r
24                 #endregion\r
25 \r
26                 #region IExtensionPoint Members\r
27                 /// <summary>\r
28                 /// Get the name of this extension point\r
29                 /// </summary>\r
30                 public string Name\r
31                 {\r
32                         get { return this.name; }\r
33                 }\r
34 \r
35                 /// <summary>\r
36                 /// Get the host that provides this extension point\r
37                 /// </summary>\r
38                 public IExtensionHost Host\r
39                 {\r
40                         get { return this.host; }\r
41                 }\r
42 \r
43                 /// <summary>\r
44                 /// Install an extension at this extension point. If the\r
45                 /// extension object does not meet the requirements for\r
46                 /// this extension point, an exception is thrown.\r
47                 /// </summary>\r
48                 /// <param name="extension">The extension to install</param>\r
49                 public void Install(object extension)\r
50                 {\r
51                         if ( !ValidExtension( extension ) )\r
52                                 throw new ArgumentException( \r
53                                         extension.GetType().FullName + " is not {0} extension point", "extension" );\r
54 \r
55                         extensions.Add( extension );\r
56                 }\r
57 \r
58                 /// <summary>\r
59                 /// Removes an extension from this extension point. If the\r
60                 /// extension object is not present, the method returns\r
61                 /// without error.\r
62                 /// </summary>\r
63                 /// <param name="extension"></param>\r
64                 public void Remove(object extension)\r
65                 {\r
66                         extensions.Remove( extension );\r
67                 }\r
68                 #endregion\r
69 \r
70                 #region Abstract Methods\r
71                 protected abstract bool ValidExtension(object extension);\r
72                 #endregion\r
73         }\r
74 }\r