Merge branch 'master' of http://github.com/mono/mono
[mono.git] / mcs / nunit24 / NUnitCore / interfaces / Extensibility / Addin.cs
1 // ****************************************************************\r
2 // Copyright 2007, Charlie Poole\r
3 // This is free software licensed under the NUnit license. You may\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4\r
5 // ****************************************************************\r
6 using System;\r
7 using System.Reflection;\r
8 \r
9 namespace NUnit.Core.Extensibility\r
10 {\r
11         /// <summary>\r
12         /// The Addin class holds information about an addin.\r
13         /// </summary>\r
14         [Serializable]\r
15         public class Addin\r
16         {\r
17                 #region Private Fields\r
18                 private string typeName;\r
19                 private string name;\r
20                 private string description;\r
21                 private ExtensionType extensionType;\r
22                 private AddinStatus status;\r
23                 private string message;\r
24                 #endregion\r
25 \r
26                 #region Constructor\r
27                 /// <summary>\r
28                 /// Construct an Addin for a type.\r
29                 /// </summary>\r
30                 /// <param name="type">The type to be used</param>\r
31                 public Addin( Type type )\r
32                 {\r
33                         this.typeName = type.AssemblyQualifiedName;\r
34 \r
35                         object[] attrs = type.GetCustomAttributes( typeof(NUnitAddinAttribute), false );\r
36                         if ( attrs.Length == 1 )\r
37                         {\r
38                                 NUnitAddinAttribute attr = (NUnitAddinAttribute)attrs[0];\r
39                                 this.name = attr.Name;\r
40                                 this.description = attr.Description;\r
41                                 this.extensionType = attr.Type;\r
42                         }\r
43 \r
44                         if ( this.name == null )\r
45                                 this.name = type.Name;\r
46 \r
47                         if ( this.extensionType == 0 )\r
48                                 this.extensionType = ExtensionType.Core;\r
49 \r
50                         this.status = AddinStatus.Enabled;\r
51         }\r
52                 #endregion\r
53 \r
54                 #region Properties\r
55                 /// <summary>\r
56                 /// The name of the Addin\r
57                 /// </summary>\r
58                 public string Name\r
59                 {\r
60                         get { return name; }\r
61                 }\r
62 \r
63                 /// <summary>\r
64                 /// Brief description of what the Addin does\r
65                 /// </summary>\r
66                 public string Description\r
67                 {\r
68                         get { return description; }\r
69                 }\r
70 \r
71                 /// <summary>\r
72                 /// The type or types of extension provided, using \r
73                 /// one or more members of the ExtensionType enumeration.\r
74                 /// </summary>\r
75                 public ExtensionType ExtensionType\r
76                 {\r
77                         get { return extensionType; }\r
78                 }\r
79 \r
80                 /// <summary>\r
81                 /// The AssemblyQualifiedName of the type that implements\r
82                 /// the addin.\r
83                 /// </summary>\r
84                 public string TypeName\r
85                 {\r
86                         get { return typeName; }\r
87                 }\r
88 \r
89                 /// <summary>\r
90                 /// The status of the addin\r
91                 /// </summary>\r
92                 public AddinStatus Status\r
93                 {\r
94                         get { return status; }\r
95                         set { status = value; }\r
96                 }\r
97 \r
98                 /// <summary>\r
99                 /// Any message that clarifies the status of the Addin,\r
100                 /// such as an error message or an explanation of why\r
101                 /// the addin is disabled.\r
102                 /// </summary>\r
103                 public string Message\r
104                 {\r
105                         get { return message; }\r
106                         set { message = value; }\r
107                 }\r
108                 #endregion\r
109         }\r
110 }\r