Fixing an issue with output parameters that are of type IntPtr
[castle.git] / InversionOfControl / Castle.MicroKernel / Facilities / AbstractFacility.cs
blobfd7ad99dc0ea49a66439c21fbe19cb2aa3a0b5d0
1 // Copyright 2004-2008 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.Facilities
17 using System;
19 using Castle.Core.Configuration;
21 /// <summary>
22 /// Base class for facilities.
23 /// </summary>
24 public abstract class AbstractFacility : IFacility, IDisposable
26 private IKernel kernel;
27 private IConfiguration facilityConfig;
29 /// <summary>
30 /// Gets the <see cref="IKernel"/> where the facility is registered.
31 /// </summary>
32 /// <value>The <see cref="IKernel"/>.</value>
33 public IKernel Kernel
35 get { return kernel; }
38 /// <summary>
39 /// Gets the facility configuration.
40 /// </summary>
41 /// <value>The <see cref="IConfiguration"/> representing
42 /// the facility configuration.</value>
43 public IConfiguration FacilityConfig
45 get { return facilityConfig; }
48 /// <summary>
49 /// The custom initialization for the Facility.
50 /// </summary>
51 /// <remarks>It must be overriden.</remarks>
52 protected abstract void Init();
54 #region IFacility Members
56 /// <summary>
57 /// Initializes the facility. First it performs the initialization common for all
58 /// facilities, setting the <see cref="Kernel"/> and the
59 /// <see cref="FacilityConfig"/>. After it, the <c>Init</c> method is invoked
60 /// and the custom initilization is perfomed.
61 /// </summary>
62 /// <param name="kernel"></param>
63 /// <param name="facilityConfig"></param>
64 public void Init(IKernel kernel, IConfiguration facilityConfig)
66 this.kernel = kernel;
67 this.facilityConfig = facilityConfig;
69 Init();
72 /// <summary>
73 /// Terminates the Facility, invokind the <see cref="Dispose"/> and setting
74 /// the Kernel to a null reference.
75 /// </summary>
76 public void Terminate()
78 Dispose();
80 kernel = null;
83 #endregion
85 #region IDisposable Members
87 /// <summary>
88 /// Performs the tasks associated with freeing, releasing, or resetting
89 /// the facility resources.
90 /// </summary>
91 /// <remarks>It can be overriden.</remarks>
92 public virtual void Dispose()
96 #endregion