Reverted DictionaryComponentAttribute changes.
[castle.git] / InversionOfControl / Castle.Windsor / IWindsorContainer.cs
blobc83e64e677c1a53ea91e5988578879a144b7ff7c
1 // Copyright 2004-2007 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;
22 /// <summary>
23 /// The <c>IWindsorContainer</c> interface exposes all the
24 /// functionality the Windsor implements.
25 /// </summary>
26 public interface IWindsorContainer : IServiceProviderEx, IDisposable
28 /// <summary>
29 /// Gets the container's name
30 /// </summary>
31 /// <remarks>
32 /// Only useful when child containers are being used
33 /// </remarks>
34 /// <value>The container's name.</value>
35 string Name { get; }
37 /// <summary>
38 /// Registers a facility within the kernel.
39 /// </summary>
40 /// <param name="key">The key by which the <see cref="IFacility"/> gets indexed.</param>
41 /// <param name="facility">The <see cref="IFacility"/> to add to the container.</param>
42 void AddFacility(String key, IFacility facility);
44 /// <summary>
45 /// Adds a component to be managed by the container
46 /// </summary>
47 /// <param name="key">The key by which the component gets indexed.</param>
48 /// <param name="classType">The <see cref="Type"/> to manage.</param>
49 void AddComponent(String key, Type classType);
51 /// <summary>
52 /// Adds a component to be managed by the container
53 /// </summary>
54 /// <param name="key">The key by which the component gets indexed.</param>
55 /// <param name="serviceType">The service <see cref="Type"/> that the component implements.</param>
56 /// <param name="classType">The <see cref="Type"/> to manage.</param>
57 void AddComponent(String key, Type serviceType, Type classType);
59 /// <summary>
60 /// Adds a component to be managed by the container
61 /// </summary>
62 /// <param name="key">The key by which the component gets indexed.</param>
63 /// <param name="classType">The <see cref="Type"/> to manage.</param>
64 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
65 void AddComponentWithLifestyle(String key, Type classType, LifestyleType lifestyle);
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 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
74 void AddComponentWithLifestyle(String key, Type serviceType, Type classType, LifestyleType lifestyle);
76 /// <summary>
77 /// Adds a concrete class as a component and specify the extended properties.
78 /// Used by facilities, mostly.
79 /// </summary>
80 /// <param name="key"></param>
81 /// <param name="classType"></param>
82 /// <param name="extendedProperties"></param>
83 void AddComponentWithProperties(String key, Type classType, IDictionary extendedProperties);
85 /// <summary>
86 /// Adds a concrete class and an interface
87 /// as a component and specify the extended properties.
88 /// Used by facilities, mostly.
89 /// </summary>
90 /// <param name="key"></param>
91 /// <param name="serviceType"></param>
92 /// <param name="classType"></param>
93 /// <param name="extendedProperties"></param>
94 void AddComponentWithProperties(String key, Type serviceType, Type classType, IDictionary extendedProperties);
96 /// <summary>
97 /// Adds a component to be managed by the container.
98 /// The key to obtain the component will be the FullName of the type.
99 /// </summary>
100 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
101 void AddComponent<T>();
103 /// <summary>
104 /// Adds a component to be managed by the container
105 /// </summary>
106 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
107 /// <param name="key">The key by which the component gets indexed.</param>
108 void AddComponent<T>(String key);
110 /// <summary>
111 /// Adds a component to be managed by the container.
112 /// The key to obtain the component will be the FullName of the type.
113 /// </summary>
114 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
115 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
116 void AddComponentWithLifestyle<T>(LifestyleType lifestyle);
118 /// <summary>
119 /// Adds a component to be managed by the container
120 /// </summary>
121 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
122 /// <param name="key">The key by which the component gets indexed.</param>
123 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
124 void AddComponentWithLifestyle<T>(String key, LifestyleType lifestyle);
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="I">The service <see cref="Type"/> that the component implements.</typeparam>
131 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
132 void AddComponent<I, T>() where T : class;
134 /// <summary>
135 /// Adds a component to be managed by the container
136 /// </summary>
137 /// <typeparam name="I">The service <see cref="Type"/> that the component implements.</typeparam>
138 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
139 /// <param name="key">The key by which the component gets indexed.</param>
140 void AddComponent<I, T>(String key) where T : class;
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 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
149 void AddComponentWithLifestyle<I, T>(LifestyleType lifestyle) where T : class;
151 /// <summary>
152 /// Adds a component to be managed by the container
153 /// </summary>
154 /// <typeparam name="I">The service <see cref="Type"/> that the component implements.</typeparam>
155 /// <typeparam name="T">The <see cref="Type"/> to manage.</typeparam>
156 /// <param name="key">The key by which the component gets indexed.</param>
157 /// <param name="lifestyle">The <see cref="LifestyleType"/> with which to manage the component.</param>
158 void AddComponentWithLifestyle<I, T>(String key, LifestyleType lifestyle) where T : class;
160 /// <summary>
161 /// Adds a concrete class as a component and specify the extended properties.
162 /// Used by facilities, mostly.
163 /// The key to obtain the component will be the FullName of the type.
164 /// </summary>
165 /// <typeparam name="T"></typeparam>
166 /// <param name="extendedProperties"></param>
167 void AddComponentWithProperties<T>(IDictionary extendedProperties);
169 /// <summary>
170 /// Adds a concrete class as a component and specify the extended properties.
171 /// Used by facilities, mostly.
172 /// </summary>
173 /// <typeparam name="T"></typeparam>
174 /// <param name="key"></param>
175 /// <param name="extendedProperties"></param>
176 void AddComponentWithProperties<T>(String key, IDictionary extendedProperties);
178 /// <summary>
179 /// Adds a concrete class and an interface
180 /// as a component and specify the extended properties.
181 /// Used by facilities, mostly.
182 /// The key to obtain the component will be the FullName of the type.
183 /// </summary>
184 /// <typeparam name="I"></typeparam>
185 /// <typeparam name="T"></typeparam>
186 /// <param name="extendedProperties"></param>
187 void AddComponentWithLifestyle<I, T>(IDictionary extendedProperties) where T : class;
189 /// <summary>
190 /// Adds a concrete class and an interface
191 /// as a component and specify the extended properties.
192 /// Used by facilities, mostly.
193 /// </summary>
194 /// <typeparam name="I"></typeparam>
195 /// <typeparam name="T"></typeparam>
196 /// <param name="key"></param>
197 /// <param name="extendedProperties"></param>
198 void AddComponentWithLifestyle<I, T>(String key, IDictionary extendedProperties) where T : class;
200 /// <summary>
201 /// Returns a component instance by the key
202 /// </summary>
203 /// <param name="key"></param>
204 /// <returns></returns>
205 object Resolve(String key);
207 /// <summary>
208 /// Returns a component instance by the key
209 /// </summary>
210 /// <param name="key"></param>
211 /// <param name="arguments"></param>
212 /// <returns></returns>
213 object Resolve(String key, IDictionary arguments);
215 /// <summary>
216 /// Returns a component instance by the key
217 /// </summary>
218 /// <param name="key"></param>
219 /// <param name="service"></param>
220 /// <returns></returns>
221 object Resolve(String key, Type service);
223 /// <summary>
224 /// Returns a component instance by the service
225 /// </summary>
226 /// <param name="service"></param>
227 /// <returns></returns>
228 object Resolve(Type service);
230 /// <summary>
231 /// Returns a component instance by the service
232 /// </summary>
233 /// <param name="service"></param>
234 /// <param name="arguments"></param>
235 /// <returns></returns>
236 object Resolve(Type service, IDictionary arguments);
238 /// <summary>
239 /// Releases a component instance
240 /// </summary>
241 /// <param name="instance"></param>
242 void Release(object instance);
244 /// <summary>
245 /// Registers a subcontainer. The components exposed
246 /// by this container will be accessible from subcontainers.
247 /// </summary>
248 /// <param name="childContainer"></param>
249 void AddChildContainer(IWindsorContainer childContainer);
251 /// <summary>
252 /// Remove a child container
253 /// </summary>
254 /// <param name="childContainer"></param>
255 void RemoveChildContainer(IWindsorContainer childContainer);
257 /// <summary>
258 /// Shortcut to <see cref="Resolve(string)"/>
259 /// </summary>
260 object this [String key] { get; }
262 /// <summary>
263 /// Shortcut to <see cref="Resolve(Type)"/>
264 /// </summary>
265 object this [Type service] { get; }
267 /// <summary>
268 /// Gets a child container instance by name.
269 /// </summary>
270 /// <param name="name">The container's name.</param>
271 /// <returns>The child container instance or null</returns>
272 IWindsorContainer GetChildContainer(string name);
274 /// <summary>
275 /// Returns a component instance by the service
276 /// </summary>
277 /// <typeparam name="T">Service type</typeparam>
278 /// <returns>The component instance</returns>
279 T Resolve<T>();
281 /// <summary>
282 /// Returns a component instance by the service
283 /// </summary>
284 /// <typeparam name="T">Service type</typeparam>
285 /// <param name="arguments"></param>
286 /// <returns>The component instance</returns>
287 T Resolve<T>(IDictionary arguments);
289 /// <summary>
290 /// Returns a component instance by the key
291 /// </summary>
292 /// <param name="key">Component's key</param>
293 /// <typeparam name="T">Service type</typeparam>
294 /// <returns>The Component instance</returns>
295 T Resolve<T>(String key);
297 /// <summary>
298 /// Returns a component instance by the key
299 /// </summary>
300 /// <typeparam name="T">Service type</typeparam>
301 /// <param name="key">Component's key</param>
302 /// <param name="arguments"></param>
303 /// <returns>The Component instance</returns>
304 T Resolve<T>(String key, IDictionary arguments);
307 /// <summary>
308 /// Returns a component instance by the key
309 /// </summary>
310 /// <param name="key"></param>
311 /// <param name="service"></param>
312 /// <param name="arguments"></param>
313 /// <returns></returns>
314 object Resolve(String key, Type service, IDictionary arguments);
316 /// <summary>
317 /// Returns the inner instance of the MicroKernel
318 /// </summary>
319 IKernel Kernel { get; }
321 /// <summary>
322 /// Gets or sets the parent container if this instance
323 /// is a sub container.
324 /// </summary>
325 IWindsorContainer Parent { get; set; }