Supporting dynamically genereted signed assemblies
[castle.git] / InversionOfControl / Castle.Windsor / IWindsorContainer.cs
blobcded0b88a081194309f0d7b9f1ce1be43bda7a11
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 : 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 /// Returns a component instance by the key
98 /// </summary>
99 /// <param name="key"></param>
100 /// <returns></returns>
101 object Resolve(String key);
103 /// <summary>
104 /// Returns a component instance by the key
105 /// </summary>
106 /// <param name="key"></param>
107 /// <param name="arguments"></param>
108 /// <returns></returns>
109 object Resolve(String key, IDictionary arguments);
111 #if DOTNET2
113 /// <summary>
114 /// Returns a component instance by the key
115 /// </summary>
116 /// <param name="key"></param>
117 /// <param name="service"></param>
118 /// <returns></returns>
119 object Resolve(String key, Type service);
121 #endif
123 /// <summary>
124 /// Returns a component instance by the service
125 /// </summary>
126 /// <param name="service"></param>
127 /// <returns></returns>
128 object Resolve(Type service);
130 /// <summary>
131 /// Returns a component instance by the service
132 /// </summary>
133 /// <param name="service"></param>
134 /// <param name="arguments"></param>
135 /// <returns></returns>
136 object Resolve(Type service, IDictionary arguments);
138 /// <summary>
139 /// Releases a component instance
140 /// </summary>
141 /// <param name="instance"></param>
142 void Release(object instance);
144 /// <summary>
145 /// Registers a subcontainer. The components exposed
146 /// by this container will be accessible from subcontainers.
147 /// </summary>
148 /// <param name="childContainer"></param>
149 void AddChildContainer(IWindsorContainer childContainer);
151 /// <summary>
152 /// Remove a child container
153 /// </summary>
154 /// <param name="childContainer"></param>
155 void RemoveChildContainer(IWindsorContainer childContainer);
157 /// <summary>
158 /// Shortcut to <see cref="Resolve(string)"/>
159 /// </summary>
160 object this [String key] { get; }
162 /// <summary>
163 /// Shortcut to <see cref="Resolve(Type)"/>
164 /// </summary>
165 object this [Type service] { get; }
167 /// <summary>
168 /// Gets a child container instance by name.
169 /// </summary>
170 /// <param name="name">The container's name.</param>
171 /// <returns>The child container instance or null</returns>
172 IWindsorContainer GetChildContainer(string name);
174 #if DOTNET2
176 /// <summary>
177 /// Returns a component instance by the service
178 /// </summary>
179 /// <typeparam name="T">Service type</typeparam>
180 /// <returns>The component instance</returns>
181 T Resolve<T>();
183 /// <summary>
184 /// Returns a component instance by the service
185 /// </summary>
186 /// <typeparam name="T">Service type</typeparam>
187 /// <param name="arguments"></param>
188 /// <returns>The component instance</returns>
189 T Resolve<T>(IDictionary arguments);
191 /// <summary>
192 /// Returns a component instance by the key
193 /// </summary>
194 /// <param name="key">Component's key</param>
195 /// <typeparam name="T">Service type</typeparam>
196 /// <returns>The Component instance</returns>
197 T Resolve<T>(String key);
199 /// <summary>
200 /// Returns a component instance by the key
201 /// </summary>
202 /// <typeparam name="T">Service type</typeparam>
203 /// <param name="key">Component's key</param>
204 /// <param name="arguments"></param>
205 /// <returns>The Component instance</returns>
206 T Resolve<T>(String key, IDictionary arguments);
209 /// <summary>
210 /// Returns a component instance by the key
211 /// </summary>
212 /// <param name="key"></param>
213 /// <param name="service"></param>
214 /// <param name="arguments"></param>
215 /// <returns></returns>
216 object Resolve(String key, Type service, IDictionary arguments);
218 #endif
220 /// <summary>
221 /// Returns the inner instance of the MicroKernel
222 /// </summary>
223 IKernel Kernel { get; }
225 /// <summary>
226 /// Gets or sets the parent container if this instance
227 /// is a sub container.
228 /// </summary>
229 IWindsorContainer Parent { get; set; }