PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/NUnit/util/Services/AddinRegistry.cs

#
C# | 81 lines | 61 code | 12 blank | 8 comment | 5 complexity | e9487fbb1905f53946ad6badf05229a5 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// ****************************************************************
 6
 7using System;
 8using System.Collections;
 9using System.Reflection;
10using NUnit.Core;
11using NUnit.Core.Extensibility;
12
13namespace NUnit.Util
14{
15	/// <summary>
16	/// Summary description for AddinRegistry.
17	/// </summary>
18	public class AddinRegistry : MarshalByRefObject, IAddinRegistry, IService
19    {
20        #region Instance Fields
21        private ArrayList addins = new ArrayList();
22		#endregion
23
24		#region IAddinRegistry Members
25
26		public void Register(Addin addin)
27		{
28			addins.Add( addin );
29		}
30
31		public  IList Addins
32		{
33			get
34			{
35				return addins;
36			}
37		}
38
39        public bool IsAddinRegistered(string name)
40        {
41            return FindAddinByName(name) != null;
42        }
43
44		public void SetStatus( string name, AddinStatus status, string message )
45		{
46            Addin addin = FindAddinByName(name);
47            if (addin != null)
48            {
49                addin.Status = status;
50                addin.Message = message;
51            }
52        }
53
54        private Addin FindAddinByName(string name)
55        {
56            foreach (Addin addin in addins)
57                if (addin.Name == name)
58                    return addin;
59
60            return null;
61        }
62		#endregion
63
64		#region IService Members
65		public void InitializeService()
66		{
67		}
68
69		public void UnloadService()
70		{
71		}
72		#endregion
73
74        #region InitializeLifetimeService
75        public override object InitializeLifetimeService()
76        {
77            return null;
78        }
79        #endregion
80    }
81}