Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Samples / PestControl / Castle.Applications.PestControl / Services / SourceControl / SourceControlManager.cs
blob61220d65764e33d9971d4446aaa0617d9ba62d66
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.SourceControl
17 using System;
19 using System.Collections;
21 using Castle.Core;
23 using Castle.MicroKernel;
25 /// <summary>
26 /// Summary description for SourceControlManager.
27 /// </summary>
28 public class SourceControlManager : IInitializable, IDisposable
30 private IKernel _kernel;
32 public SourceControlManager(IKernel kernel)
34 _kernel = kernel;
37 public void Initialize()
41 public void Dispose()
43 // _kernel = null;
46 /// <summary>
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
52 /// </summary>
53 /// <remarks>
54 /// This approach invokes Resolve on the handler,
55 /// but do not invoke the counter part release.
56 /// </remarks>
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) );