Fixing Brail Templates for VS Net wizards.
[castle.git] / ActiveRecord / Castle.ActiveRecord / Framework / ISessionFactoryHolder.cs
bloba52dbc11bd913d9eed2d0213bc6aec3abae4f3d5
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.ActiveRecord.Framework
17 using System;
19 using NHibernate;
20 using NHibernate.Cfg;
22 /// <summary>
23 /// Type of delegate that is called when a root type is registered.
24 /// </summary>
25 /// <param name="sender"></param>
26 /// <param name="rootType"></param>
27 public delegate void RootTypeHandler(object sender, Type rootType);
29 /// <summary>
30 /// Keeps an association of SessionFactories to a object model
31 /// tree;
32 /// </summary>
33 public interface ISessionFactoryHolder
35 /// <summary>
36 /// Raised when a new root type is registered.
37 /// A new root type creates a new <c>ISessionFactory</c>
38 /// </summary>
39 event RootTypeHandler OnRootTypeRegistered;
41 /// <summary>
42 /// Associates a Configuration object to a root type
43 /// </summary>
44 /// <param name="rootType"></param>
45 /// <param name="cfg"></param>
46 void Register(Type rootType, Configuration cfg);
48 /// <summary>
49 /// Pendent
50 /// </summary>
51 /// <returns></returns>
52 Configuration[] GetAllConfigurations();
54 /// <summary>
55 /// Requests the Configuration associated to the type.
56 /// </summary>
57 /// <param name="type"></param>
58 /// <returns></returns>
59 Configuration GetConfiguration(Type type);
61 /// <summary>
62 /// Obtains the SessionFactory associated to the type.
63 /// </summary>
64 /// <param name="type"></param>
65 /// <returns></returns>
66 ISessionFactory GetSessionFactory(Type type);
68 /// <summary>
69 /// Creates a session for the associated type
70 /// </summary>
71 /// <param name="type"></param>
72 /// <returns></returns>
73 ISession CreateSession(Type type);
75 /// <summary>
76 /// Releases the specified session
77 /// </summary>
78 /// <param name="session"></param>
79 void ReleaseSession(ISession session);
81 /// <summary>
82 /// Called if an action on the session fails
83 /// </summary>
84 /// <param name="session"></param>
85 void FailSession(ISession session);
87 /// <summary>
88 /// Gets the type of the root.
89 /// </summary>
90 /// <param name="type">The type.</param>
91 /// <returns></returns>
92 Type GetRootType(Type type);
94 /// <summary>
95 /// Gets or sets the implementation of <see cref="IThreadScopeInfo"/>
96 /// </summary>
97 IThreadScopeInfo ThreadScopeInfo { get; set; }
99 ///<summary>
100 /// This method allows direct registration
101 /// of a session factory to a type, bypassing the normal preperation that AR
102 /// usually does.
103 /// The main usage is in testing, so you would be able to switch the session factory
104 /// for each test.
105 /// Note that this will override the current session factory for the baseType.
106 ///</summary>
107 void RegisterSessionFactory(ISessionFactory sessionFactory, Type baseType);