Applying commutative patch from Roy Tate:
[castle.git] / InversionOfControl / Castle.MicroKernel / IKernelEvents.cs
blob5c11169fdced47b88f66c6b5172d29370dae9c82
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 using System;
19 using Castle.Core;
21 /// <summary>
22 /// Represents a delegate which holds basic information about a component.
23 /// </summary>
24 /// <param name="key">Key which identifies the component</param>
25 /// <param name="handler">handler that holds this component and is capable of
26 /// creating an instance of it.
27 /// </param>
28 public delegate void ComponentDataDelegate( String key, IHandler handler );
30 /// <summary>
31 /// Represents a delegate which holds basic information about a component
32 /// and its instance.
33 /// </summary>
34 /// <param name="model">Component meta information</param>
35 /// <param name="instance">Component instance</param>
36 public delegate void ComponentInstanceDelegate( ComponentModel model, object instance );
38 /// <summary>
39 /// Represents a delegate which holds the information about the
40 /// component
41 /// </summary>
42 public delegate void ComponentModelDelegate( ComponentModel model );
44 /// <summary>
45 /// Represents a delegate which holds a handler
46 /// </summary>
47 /// <param name="handler">handler that holds a component and is capable of
48 /// creating an instance of it.
49 /// </param>
50 /// <param name="stateChanged"></param>
51 public delegate void HandlerDelegate( IHandler handler, ref bool stateChanged );
53 /// <summary>
54 /// Represents a delegate which holds dependency
55 /// resolving information.
56 /// </summary>
57 public delegate void DependencyDelegate(ComponentModel client, DependencyModel model, Object dependency);
59 /// <summary>
60 /// Summary description for IKernelEvents.
61 /// </summary>
62 public interface IKernelEvents
64 /// <summary>
65 /// Event fired when a new component is registered
66 /// on the kernel.
67 /// </summary>
68 event ComponentDataDelegate ComponentRegistered;
70 /// <summary>
71 /// Event fired when a component is removed from the kernel.
72 /// </summary>
73 event ComponentDataDelegate ComponentUnregistered;
75 /// <summary>
76 /// Event fired after the ComponentModel is created.
77 /// Allows customizations that may affect the handler.
78 /// </summary>
79 event ComponentModelDelegate ComponentModelCreated;
81 /// <summary>
82 /// Event fired when the kernel was added as child of
83 /// another kernel.
84 /// </summary>
85 event EventHandler AddedAsChildKernel;
87 /// <summary>
88 /// Event fired when the kernel was removed from being a child
89 /// of another kernel.
90 /// </summary>
91 event EventHandler RemovedAsChildKernel;
93 /// <summary>
94 /// Event fired before the component is created.
95 /// </summary>
96 event ComponentInstanceDelegate ComponentCreated;
98 /// <summary>
99 /// Event fired when a component instance destroyed.
100 /// </summary>
101 event ComponentInstanceDelegate ComponentDestroyed;
103 /// <summary>
104 /// Event fired when a new handler is registered
105 /// (it might be in a valid or waiting dependency state)
106 /// </summary>
107 event HandlerDelegate HandlerRegistered;
109 /// <summary>
110 /// Event fired when a dependency is being resolved,
111 /// it allows the dependency to be changed,
112 /// but the client ComponentModel must not be altered.
113 /// </summary>
114 event DependencyDelegate DependencyResolving;