| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
SessionContainer\WebSessionContainer.cs | - | 0.0 % | 0.0 % | 0.0 % |
|
1 | ||
2 | #region Apache Notice | |
3 | /***************************************************************************** | |
4 | * $Header: $ | |
5 | * $Revision: $ | |
6 | * $Date: $ | |
7 | * | |
8 | * iBATIS.NET Data Mapper | |
9 | * Copyright (C) 2004 - Gilles Bayon | |
10 | * | |
11 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
12 | * you may not use this file except in compliance with the License. | |
13 | * You may obtain a copy of the License at | |
14 | * | |
15 | * http://www.apache.org/licenses/LICENSE-2.0 | |
16 | * | |
17 | * Unless required by applicable law or agreed to in writing, software | |
18 | * distributed under the License is distributed on an "AS IS" BASIS, | |
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
20 | * See the License for the specific language governing permissions and | |
21 | * limitations under the License. | |
22 | * | |
23 | ********************************************************************************/ | |
24 | #endregion | |
25 | ||
26 | #region Imports | |
27 | using System; | |
28 | using System.Runtime.Remoting.Messaging; | |
29 | ||
30 | using IBatisNet.Common; | |
31 | #endregion | |
32 | ||
33 | namespace IBatisNet.DataMapper.SessionContainer | |
34 | { | |
35 | /// <summary> | |
36 | /// Session container for web application. | |
37 | /// </summary> | |
38 | public class WebSessionContainer : ISessionContainer | |
39 | { | |
40 | ||
41 | #region Constants | |
42 | ||
43 | /// <summary> | |
44 | /// Token for SqlMapConfig xml root. | |
45 | /// </summary> | |
46 | private const string LOCAL_SESSION = "_IBATIS_LOCAL_SQLMAPSESSION_"; | |
47 | ||
48 | #endregion | |
49 | ||
50 | #region Fields | |
51 | private string _sessionName = string.Empty; | |
52 | #endregion | |
53 | ||
54 | #region Constructor (s) / Destructor | |
55 | ||
56 | /// <summary> | |
57 | /// Constructor | |
58 | /// </summary> | |
59 | 0 | public WebSessionContainer(string sqlMapperName) |
60 | { | |
61 | _sessionName = LOCAL_SESSION+sqlMapperName; | |
62 | CallContext.SetData(_sessionName, null); | |
63 | } | |
64 | #endregion | |
65 | ||
66 | #region ISessionContainer Members | |
67 | ||
68 | #region Properties | |
69 | /// <summary> | |
70 | /// Get the local session | |
71 | /// </summary> | |
72 | 0 | public SqlMapSession LocalSession |
73 | { | |
74 | get | |
75 | { | |
76 | return CallContext.GetData(_sessionName) as SqlMapSession; | |
77 | } | |
78 | } | |
79 | #endregion | |
80 | ||
81 | #region Methods | |
82 | /// <summary> | |
83 | /// Store the local session on the container. | |
84 | /// Ensure that the session is unique for each thread. | |
85 | /// </summary> | |
86 | /// <param name="session">The session to store</param> | |
87 | 0 | public void Store(SqlMapSession session) |
88 | { | |
89 | CallContext.SetData(_sessionName, session); | |
90 | } | |
91 | ||
92 | /// <summary> | |
93 | /// Remove the local session from the container. | |
94 | /// </summary> | |
95 | 0 | public void Dispose() |
96 | { | |
97 | CallContext.SetData(_sessionName, null); | |
98 | } | |
99 | ||
100 | #endregion | |
101 | ||
102 | #endregion | |
103 | } | |
104 | } | |
105 |
|