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
.SourceControl
19 using System
.Collections
;
23 using Castle
.MicroKernel
;
26 /// Summary description for SourceControlManager.
28 public class SourceControlManager
: IInitializable
, IDisposable
30 private IKernel _kernel
;
32 public SourceControlManager(IKernel kernel
)
37 public void Initialize()
47 /// Queries the kernel for implementations of ISourceControl.
48 /// This allow new build system to be registered even without
49 /// restarting the application. A more efficient approach however
50 /// is to issue this query only once, but then you lost the ability
51 /// to add/remove buildsystems at runtime
54 /// This approach invokes Resolve on the handler,
55 /// but do not invoke the counter part release.
57 /// <returns></returns>
58 public virtual ISourceControl
[] AvailableSourceControl()
60 ArrayList list
= new ArrayList();
62 IHandler
[] handlers
= _kernel
.GetHandlers( typeof(ISourceControl
) );
64 foreach(IHandler handler
in handlers
)
66 if (handler
.CurrentState
== HandlerState
.Valid
)
68 list
.Add( handler
.Resolve(CreationContext
.Empty
) );
72 return (ISourceControl
[]) list
.ToArray( typeof(ISourceControl
) );