| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
SessionContainer\SessionContainerFactory.cs | 50.0 % | 66.7 % | 100.0 % | 66.7 % |
|
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.Web; | |
29 | #endregion | |
30 | ||
31 | namespace IBatisNet.DataMapper.SessionContainer | |
32 | { | |
33 | /// <summary> | |
34 | /// Build a session container for a Windows or Web context. | |
35 | /// When running in the context of a web application the session object is | |
36 | /// stored in HttpContext items and has 'per request' lifetime. | |
37 | /// When running in the context of a windows application the session object is | |
38 | /// stored in a with a TLS (ThreadLocalStorage). | |
39 | /// </summary> | |
40 | public class SessionContainerFactory | |
41 | { | |
42 | #region Methods | |
43 | /// <summary> | |
44 | /// Get a session container for a Windows or Web context. | |
45 | /// </summary> | |
46 | /// <returns></returns> | |
47 | 170 | static public ISessionContainer GetSessionContainer(string sqlMapperName) |
48 | { | |
49 | 170 | if (System.Web.HttpContext.Current == null) |
50 | { | |
51 | 170 | return new WindowSessionContainer(); |
52 | } | |
53 | else | |
54 | { | |
55 | 0 | return new WebSessionContainer(sqlMapperName); |
56 | } | |
57 | } | |
58 | #endregion | |
59 | } | |
60 | } | |
61 |
|