Fixing an issue with output parameters that are of type IntPtr
[castle.git] / InversionOfControl / Castle.Windsor / IWindsorContainer.cs
blobc4f7f96b6a9ce7653bf3bc42f3287ff95209e6ec
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.Windsor
17 using System;
18 using System.Collections;
19 using Castle.Core;
20 using Castle.MicroKernel;
21 using Castle.MicroKernel.Registration;
23 /// <summary>
24 /// The <c>IWindsorContainer</c> interface exposes all the
25 /// functionality the Windsor implements.
26 /// </summary>
27 public interface IWindsorContainer : IServiceProviderEx, IDisposable
29 /// <summary>
30 /// Gets the container's name
31 /// </summary>
32 /// <remarks>
33 /// Only useful when child containers are being used
34 /// </remarks>
35 /// <value>The container's name.</value>
36 string Name { get; }
38 /// <summary>
39 /// Registers a facility within the container.
40 /// </summary>
41 /// <param name="key">The key by which the <see cref="IFacility"/> gets indexed.</param>
42 /// <param name="facility">The <see cref="IFacility"/> to add to the container.</param>
43 IWindsorContainer AddFacility(String key, IFacility facility);
45 /// <summary>
46 /// Creates and adds an <see cref="IFacility"/> facility to the container.
47 /// </summary>
48 /// <typeparam name="T">The facility type.</typeparam>
49 /// <param name="key"></param>
50 /// <returns></returns>
51 IWindsorContainer AddFacility<T>(String key) where T : IFacility, new();
53 /// <summary>
54 /// Creates and adds an <see cref="IFacility"/> facility to the container.
55 /// </summary>
56 /// <typeparam name="T">The facility type.</typeparam>
57 /// <returns></returns>
58 IWindsorContainer AddFacility<T>() where T : IFacility, new();
60 /// <summary>
61 /// Adds a component to be managed by the container
62 /// </summary>
63 /// <param name="key">The key by which the component gets indexed.</param>
64 /// <param name="classType">The <see cref="Type"/> to manage.</param>
65 IWindsorContainer AddComponent(String key, Type classType);
67 /// <summary>
68 /// Adds a component to be managed by the container
69 /// </summary>
70 /// <param name="key">The key by which the component gets indexed.</param>
71 /// <param name="serviceType">The service <see cref="Type"/> that the component implements.</param>
72 /// <param name="classType">The <see cref="Type"/> to manage.</param>
73 IWindsorContainer AddComponent(String key, Type serviceType, Type classType);
75 /// <summary>
76 /// Adds a component to be managed by the container
77 /// </summary>
78 /// <param name="key">The key by which the component gets indexed.</param>
79 /// <param name="classType">The <see cref="Type"/> to manage.</param>
80 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
81 IWindsorContainer AddComponentLifeStyle(String key, Type classType, LifestyleType lifestyle);
83 /// <summary>
84 /// Adds a component to be managed by the container
85 /// </summary>
86 /// <param name="key">The key by which the component gets indexed.</param>
87 /// <param name="serviceType">The service <see cref="Type"/> that the component implements.</param>
88 /// <param name="classType">The <see cref="Type"/> to manage.</param>
89 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
90 IWindsorContainer AddComponentLifeStyle(String key, Type serviceType, Type classType, LifestyleType lifestyle);
92 /// <summary>
93 /// Adds a concrete class as a component and specify the extended properties.
94 /// Used by facilities, mostly.
95 /// </summary>
96 /// <param name="key"></param>
97 /// <param name="classType"></param>
98 /// <param name="extendedProperties"></param>
99 IWindsorContainer AddComponentWithProperties(String key, Type classType, IDictionary extendedProperties);
101 /// <summary>
102 /// Adds a concrete class and an interface
103 /// as a component and specify the extended properties.
104 /// Used by facilities, mostly.
105 /// </summary>
106 /// <param name="key"></param>
107 /// <param name="serviceType"></param>
108 /// <param name="classType"></param>
109 /// <param name="extendedProperties"></param>
110 IWindsorContainer AddComponentWithProperties(String key, Type serviceType, Type classType, IDictionary extendedProperties);
112 /// <summary>
113 /// Adds a component to be managed by the container.
114 /// The key to obtain the component will be the FullName of the type.
115 /// </summary>
116 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
117 IWindsorContainer AddComponent<T>();
119 /// <summary>
120 /// Adds a component to be managed by the container
121 /// </summary>
122 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
123 /// <param name="key">The key by which the component gets indexed.</param>
124 IWindsorContainer AddComponent<T>(String key);
126 /// <summary>
127 /// Adds a component to be managed by the container.
128 /// The key to obtain the component will be the FullName of the type.
129 /// </summary>
130 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
131 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
132 IWindsorContainer AddComponentLifeStyle<T>(LifestyleType lifestyle);
134 /// <summary>
135 /// Adds a component to be managed by the container
136 /// </summary>
137 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
138 /// <param name="key">The key by which the component gets indexed.</param>
139 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
140 IWindsorContainer AddComponentLifeStyle<T>(String key, LifestyleType lifestyle);
142 /// <summary>
143 /// Adds a component to be managed by the container
144 /// The key to obtain the component will be the FullName of the type.
145 /// </summary>
146 /// <typeparam name="I">The service <see cref="Type"/> that the component implements.</typeparam>
147 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
148 IWindsorContainer AddComponent<I, T>() where T : class;
150 /// <summary>
151 /// Adds a component to be managed by the container
152 /// </summary>
153 /// <typeparam name="I">The service <see cref="Type"/> that the component implements.</typeparam>
154 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
155 /// <param name="key">The key by which the component gets indexed.</param>
156 IWindsorContainer AddComponent<I, T>(String key) where T : class;
158 /// <summary>
159 /// Adds a component to be managed by the container
160 /// The key to obtain the component will be the FullName of the type.
161 /// </summary>
162 /// <typeparam name="I">The service <see cref="Type"/> that the component implements.</typeparam>
163 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
164 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
165 IWindsorContainer AddComponentLifeStyle<I, T>(LifestyleType lifestyle) where T : class;
167 /// <summary>
168 /// Adds a component to be managed by the container
169 /// </summary>
170 /// <typeparam name="I">The service <see cref="Type"/> that the component implements.</typeparam>
171 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
172 /// <param name="key">The key by which the component gets indexed.</param>
173 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
174 IWindsorContainer AddComponentLifeStyle<I, T>(String key, LifestyleType lifestyle) where T : class;
176 /// <summary>
177 /// Adds a concrete class as a component and specify the extended properties.
178 /// Used by facilities, mostly.
179 /// The key to obtain the component will be the FullName of the type.
180 /// </summary>
181 /// <typeparam name="T"></typeparam>
182 /// <param name="extendedProperties"></param>
183 IWindsorContainer AddComponentWithProperties<T>(IDictionary extendedProperties);
185 /// <summary>
186 /// Adds a concrete class as a component and specify the extended properties.
187 /// Used by facilities, mostly.
188 /// </summary>
189 /// <typeparam name="T"></typeparam>
190 /// <param name="key"></param>
191 /// <param name="extendedProperties"></param>
192 IWindsorContainer AddComponentWithProperties<T>(String key, IDictionary extendedProperties);
194 /// <summary>
195 /// Adds a concrete class and an interface
196 /// as a component and specify the extended properties.
197 /// Used by facilities, mostly.
198 /// The key to obtain the component will be the FullName of the type.
199 /// </summary>
200 /// <typeparam name="I"></typeparam>
201 /// <typeparam name="T"></typeparam>
202 /// <param name="extendedProperties"></param>
203 IWindsorContainer AddComponentLifeStyle<I, T>(IDictionary extendedProperties) where T : class;
205 /// <summary>
206 /// Adds a concrete class and an interface
207 /// as a component and specify the extended properties.
208 /// Used by facilities, mostly.
209 /// </summary>
210 /// <typeparam name="I"></typeparam>
211 /// <typeparam name="T"></typeparam>
212 /// <param name="key"></param>
213 /// <param name="extendedProperties"></param>
214 IWindsorContainer AddComponentLifeStyle<I, T>(String key, IDictionary extendedProperties) where T : class;
216 /// <summary>
217 /// Registers the components provided by the <see cref="IRegistration"/>s
218 /// with the <see cref="IWindsorContainer"/>.
219 /// <param name="registrations">The component registrations.</param>
220 /// <returns>The container.</returns>
221 /// </summary>
222 IWindsorContainer Register(params IRegistration[] registrations);
224 /// <summary>
225 /// Installs the components provided by the <see cref="IWindsorInstaller"/>s
226 /// with the <see cref="IWindsorContainer"/>.
227 /// <param name="installers">The component installers.</param>
228 /// <returns>The container.</returns>
229 /// </summary>
230 IWindsorContainer Install(params IWindsorInstaller[] installers);
232 /// <summary>
233 /// Returns a component instance by the key
234 /// </summary>
235 /// <param name="key"></param>
236 /// <returns></returns>
237 object Resolve(String key);
239 /// <summary>
240 /// Returns a component instance by the key
241 /// </summary>
242 /// <param name="key"></param>
243 /// <param name="arguments"></param>
244 /// <returns></returns>
245 object Resolve(String key, IDictionary arguments);
247 /// <summary>
248 /// Returns a component instance by the key
249 /// </summary>
250 /// <param name="key"></param>
251 /// <param name="argumentsAsAnonymousType"></param>
252 /// <returns></returns>
253 object Resolve(String key, object argumentsAsAnonymousType);
255 /// <summary>
256 /// Returns a component instance by the key
257 /// </summary>
258 /// <param name="key"></param>
259 /// <param name="service"></param>
260 /// <returns></returns>
261 object Resolve(String key, Type service);
263 /// <summary>
264 /// Returns a component instance by the service
265 /// </summary>
266 /// <param name="service"></param>
267 /// <returns></returns>
268 object Resolve(Type service);
270 /// <summary>
271 /// Returns a component instance by the service
272 /// </summary>
273 /// <param name="service"></param>
274 /// <param name="arguments"></param>
275 /// <returns></returns>
276 object Resolve(Type service, IDictionary arguments);
278 /// <summary>
279 /// Returns a component instance by the service
280 /// </summary>
281 /// <param name="service"></param>
282 /// <param name="argumentsAsAnonymousType"></param>
283 /// <returns></returns>
284 object Resolve(Type service, object argumentsAsAnonymousType);
286 /// <summary>
287 /// Releases a component instance
288 /// </summary>
289 /// <param name="instance"></param>
290 void Release(object instance);
292 /// <summary>
293 /// Registers a subcontainer. The components exposed
294 /// by this container will be accessible from subcontainers.
295 /// </summary>
296 /// <param name="childContainer"></param>
297 void AddChildContainer(IWindsorContainer childContainer);
299 /// <summary>
300 /// Remove a child container
301 /// </summary>
302 /// <param name="childContainer"></param>
303 void RemoveChildContainer(IWindsorContainer childContainer);
305 /// <summary>
306 /// Shortcut to <see cref="Resolve(string)"/>
307 /// </summary>
308 object this [String key] { get; }
310 /// <summary>
311 /// Shortcut to <see cref="Resolve(Type)"/>
312 /// </summary>
313 object this [Type service] { get; }
315 /// <summary>
316 /// Gets a child container instance by name.
317 /// </summary>
318 /// <param name="name">The container's name.</param>
319 /// <returns>The child container instance or null</returns>
320 IWindsorContainer GetChildContainer(string name);
322 /// <summary>
323 /// Returns a component instance by the service
324 /// </summary>
325 /// <typeparam name="T">Service type</typeparam>
326 /// <returns>The component instance</returns>
327 T Resolve<T>();
329 /// <summary>
330 /// Returns a component instance by the service
331 /// </summary>
332 /// <typeparam name="T">Service type</typeparam>
333 /// <param name="arguments"></param>
334 /// <returns>The component instance</returns>
335 T Resolve<T>(IDictionary arguments);
337 /// <summary>
338 /// Returns a component instance by the service
339 /// </summary>
340 /// <typeparam name="T">Service type</typeparam>
341 /// <param name="argumentsAsAnonymousType"></param>
342 /// <returns>The component instance</returns>
343 T Resolve<T>(object argumentsAsAnonymousType);
345 /// <summary>
346 /// Returns a component instance by the key
347 /// </summary>
348 /// <param name="key">Component's key</param>
349 /// <typeparam name="T">Service type</typeparam>
350 /// <returns>The Component instance</returns>
351 T Resolve<T>(String key);
353 /// <summary>
354 /// Returns a component instance by the key
355 /// </summary>
356 /// <typeparam name="T">Service type</typeparam>
357 /// <param name="key">Component's key</param>
358 /// <param name="arguments"></param>
359 /// <returns>The Component instance</returns>
360 T Resolve<T>(String key, IDictionary arguments);
362 /// <summary>
363 /// Returns a component instance by the key
364 /// </summary>
365 /// <typeparam name="T">Service type</typeparam>
366 /// <param name="key">Component's key</param>
367 /// <param name="argumentsAsAnonymousType"></param>
368 /// <returns>The Component instance</returns>
369 T Resolve<T>(String key, object argumentsAsAnonymousType);
371 /// <summary>
372 /// Returns a component instance by the key
373 /// </summary>
374 /// <param name="key"></param>
375 /// <param name="service"></param>
376 /// <param name="arguments"></param>
377 /// <returns></returns>
378 object Resolve(String key, Type service, IDictionary arguments);
380 /// <summary>
381 /// Returns a component instance by the key
382 /// </summary>
383 /// <param name="key"></param>
384 /// <param name="service"></param>
385 /// <param name="argumentsAsAnonymousType"></param>
386 /// <returns></returns>
387 object Resolve(String key, Type service, object argumentsAsAnonymousType);
389 /// <summary>
390 /// Returns the inner instance of the MicroKernel
391 /// </summary>
392 IKernel Kernel { get; }
394 /// <summary>
395 /// Gets or sets the parent container if this instance
396 /// is a sub container.
397 /// </summary>
398 IWindsorContainer Parent { get; set; }
400 /// <summary>
401 /// Resolve all valid components that match this type.
402 /// </summary>
403 /// <typeparam name="T">The service type</typeparam>
404 T[] ResolveAll<T>();
406 /// <summary>
407 /// Resolve all valid components that mathc this service
408 /// <param name="service">the service to match</param>
409 /// </summary>
410 Array ResolveAll(Type service);
412 /// <summary>
413 /// Resolve all valid components that mathc this service
414 /// <param name="service">the service to match</param>
415 /// <param name="arguments">Arguments to resolve the service</param>
416 /// </summary>
417 Array ResolveAll(Type service, IDictionary arguments);
419 /// <summary>
420 /// Resolve all valid components that mathc this service
421 /// <param name="service">the service to match</param>
422 /// <param name="argumentsAsAnonymousType">Arguments to resolve the service</param>
423 /// </summary>
424 Array ResolveAll(Type service, object argumentsAsAnonymousType);
426 /// <summary>
427 /// Resolve all valid components that match this type.
428 /// <typeparam name="T">The service type</typeparam>
429 /// <param name="arguments">Arguments to resolve the service</param>
430 /// </summary>
431 T[] ResolveAll<T>(IDictionary arguments);
433 /// <summary>
434 /// Resolve all valid components that match this type.
435 /// <typeparam name="T">The service type</typeparam>
436 /// <param name="argumentsAsAnonymousType">Arguments to resolve the service</param>
437 /// </summary>
438 T[] ResolveAll<T>(object argumentsAsAnonymousType);