Added container accessor to Castle.Core
[castle.git] / InversionOfControl / Castle.MicroKernel / ComponentActivator / IComponentActivator.cs
blob5db4ddd746a7badbae1b5d98d598d1de22443468
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.MicroKernel
17 /// <summary>
18 /// Implements the instance creation logic. The default
19 /// implementation should rely on an ordinary call to
20 /// Activator.CreateInstance().
21 /// </summary>
22 /// <remarks>
23 /// This interface is provided in order to allow custom components
24 /// to be created using a different logic, such as using a specific factory
25 /// or builder.
26 /// <para>
27 /// The constructor for implementation has the following signature:
28 /// </para>
29 /// <code>
30 /// ComponentModel model, IKernel kernel,
31 /// ComponentInstanceDelegate onCreation,
32 /// ComponentInstanceDelegate onDestruction
33 /// </code>
34 /// <para>
35 /// The Activator should raise the events onCreation and onDestruction
36 /// in order to correctly implement the contract. Usually the best
37 /// way of creating a custom activator is by extending the existing ones.
38 /// </para>
39 /// <seealso cref="ComponentActivator.AbstractComponentActivator"/>
40 /// <seealso cref="ComponentActivator.DefaultComponentActivator"/>
41 /// </remarks>
42 public interface IComponentActivator
44 /// <summary>
45 /// Should return a new component instance.
46 /// </summary>
47 /// <returns></returns>
48 object Create(CreationContext context);
50 /// <summary>
51 /// Should perform all necessary work to dispose the instance
52 /// and/or any resource related to it.
53 /// </summary>
54 /// <param name="instance"></param>
55 void Destroy(object instance);