Applied patch from Jan Limpens 'ReflectionBasedDictionaryAdapter needs to check if...
[castle.git] / Samples / PestControl / Castle.Applications.PestControl / Services / BuildSystems / BuildSystemManager.cs
blob31474e7bab192ece49e8d3b4509547236b6be645
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Applications.PestControl.Services.BuildSystems
17 using System;
18 using System.Collections;
20 using Castle.Core;
22 using Castle.MicroKernel;
24 /// <summary>
25 /// Summary description for BuildSystemManager.
26 /// </summary>
27 public class BuildSystemManager : IInitializable, IDisposable
29 private IKernel _kernel;
31 public BuildSystemManager(IKernel kernel)
33 _kernel = kernel;
36 public void Initialize()
40 public void Dispose()
42 // _kernel = null;
45 /// <summary>
46 /// Queries the kernel for implementations of IBuildSystem.
47 /// This allow new build system to be registered even without
48 /// restarting the application. A more efficient approach however
49 /// is to issue this query only once, but then you lost the ability
50 /// to add/remove buildsystems at runtime
51 /// </summary>
52 /// <remarks>
53 /// This approach invokes Resolve on the handler,
54 /// but do not invoke the counter part release.
55 /// </remarks>
56 /// <returns></returns>
57 public virtual IBuildSystem[] AvailableBuildSystems()
59 ArrayList list = new ArrayList();
61 IHandler[] handlers = _kernel.GetHandlers( typeof(IBuildSystem) );
63 foreach(IHandler handler in handlers)
65 if (handler.CurrentState == HandlerState.Valid)
67 list.Add( handler.Resolve(CreationContext.Empty) );
71 return (IBuildSystem[]) list.ToArray( typeof(IBuildSystem) );