1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 using System
.Collections
;
22 using Castle
.MicroKernel
;
25 /// Summary description for BuildSystemManager.
27 public class BuildSystemManager
: IInitializable
, IDisposable
29 private IKernel _kernel
;
31 public BuildSystemManager(IKernel kernel
)
36 public void Initialize()
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
53 /// This approach invokes Resolve on the handler,
54 /// but do not invoke the counter part release.
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
) );