// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System;
using System.Reflection;
namespace NUnit.Core.Extensibility
{
///
/// The Addin class holds information about an addin.
///
[Serializable]
public class Addin
{
#region Private Fields
private string typeName;
private string name;
private string description;
private ExtensionType extensionType;
private AddinStatus status;
private string message;
#endregion
#region Constructor
///
/// Construct an Addin for a type.
///
/// The type to be used
public Addin( Type type )
{
this.typeName = type.AssemblyQualifiedName;
object[] attrs = type.GetCustomAttributes( typeof(NUnitAddinAttribute), false );
if ( attrs.Length == 1 )
{
NUnitAddinAttribute attr = (NUnitAddinAttribute)attrs[0];
this.name = attr.Name;
this.description = attr.Description;
this.extensionType = attr.Type;
}
if ( this.name == null )
this.name = type.Name;
if ( this.extensionType == 0 )
this.extensionType = ExtensionType.Core;
this.status = AddinStatus.Enabled;
}
#endregion
#region Properties
///
/// The name of the Addin
///
public string Name
{
get { return name; }
}
///
/// Brief description of what the Addin does
///
public string Description
{
get { return description; }
}
///
/// The type or types of extension provided, using
/// one or more members of the ExtensionType enumeration.
///
public ExtensionType ExtensionType
{
get { return extensionType; }
}
///
/// The AssemblyQualifiedName of the type that implements
/// the addin.
///
public string TypeName
{
get { return typeName; }
}
///
/// The status of the addin
///
public AddinStatus Status
{
get { return status; }
set { status = value; }
}
///
/// Any message that clarifies the status of the Addin,
/// such as an error message or an explanation of why
/// the addin is disabled.
///
public string Message
{
get { return message; }
set { message = value; }
}
#endregion
}
}