1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 /// Implements the instance creation logic. The default
19 /// implementation should rely on an ordinary call to
20 /// Activator.CreateInstance().
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
27 /// The constructor for implementation has the following signature:
30 /// ComponentModel model, IKernel kernel,
31 /// ComponentInstanceDelegate onCreation,
32 /// ComponentInstanceDelegate onDestruction
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.
39 /// <seealso cref="ComponentActivator.AbstractComponentActivator"/>
40 /// <seealso cref="ComponentActivator.DefaultComponentActivator"/>
42 public interface IComponentActivator
45 /// Should return a new component instance.
47 /// <returns></returns>
48 object Create(CreationContext context
);
51 /// Should perform all necessary work to dispose the instance
52 /// and/or any resource related to it.
54 /// <param name="instance"></param>
55 void Destroy(object instance
);