1 // Copyright 2004-2008 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
21 /// The <c>ILifestyleManager</c> implements
22 /// a strategy for a given lifestyle, like singleton, perthread
26 /// The responsability of <c>ILifestyleManager</c>
27 /// is only the management of lifestyle. It should rely on
28 /// <see cref="IComponentActivator"/> to obtain a new component instance
30 public interface ILifestyleManager
: IDisposable
33 /// Initializes the <c>ILifestyleManager</c> with the
34 /// <see cref="IComponentActivator"/>
36 /// <param name="componentActivator"></param>
37 /// <param name="kernel"></param>
38 /// <param name="model"></param>
39 void Init(IComponentActivator componentActivator
, IKernel kernel
, ComponentModel model
);
42 /// Implementors should return the component instance based
43 /// on the lifestyle semantic.
45 /// <returns></returns>
46 object Resolve(CreationContext context
);
49 /// Implementors should release the component instance based
50 /// on the lifestyle semantic, for example, singleton components
51 /// should not be released on a call for release, instead they should
52 /// release them when disposed is invoked.
54 /// <param name="instance"></param>
55 void Release(object instance
);