| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
Mapper.cs | 0.0 % | 0.0 % | 0.0 % | 0.0 % |
|
1 | #region Apache Notice | |
2 | /***************************************************************************** | |
3 | * $Header: $ | |
4 | * $Revision: $ | |
5 | * $Date: $ | |
6 | * | |
7 | * iBATIS.NET Data Mapper | |
8 | * Copyright (C) 2004 - Gilles Bayon | |
9 | * | |
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 | using IBatisNet.Common.Utilities; | |
27 | using IBatisNet.DataMapper; | |
28 | ||
29 | namespace IBatisNet.DataMapper | |
30 | { | |
31 | /// <summary> | |
32 | /// A singleton class to access the default SqlMapper defined by the SqlMap.Config | |
33 | /// </summary> | |
34 | public class Mapper | |
35 | { | |
36 | #region Fields | |
37 | private static volatile SqlMapper _mapper = null; | |
38 | #endregion | |
39 | ||
40 | /// <summary> | |
41 | /// | |
42 | /// </summary> | |
43 | /// <param name="obj"></param> | |
44 | 0 | protected static void Configure (object obj) |
45 | { | |
46 | _mapper = (SqlMapper) obj; | |
47 | } | |
48 | ||
49 | /// <summary> | |
50 | /// Init the 'default' SqlMapper defined by the SqlMap.Config file. | |
51 | /// </summary> | |
52 | 0 | protected static void InitMapper() |
53 | { | |
54 | ConfigureHandler handler = new ConfigureHandler (Configure); | |
55 | _mapper = SqlMapper.ConfigureAndWatch (handler); | |
56 | } | |
57 | ||
58 | /// <summary> | |
59 | /// Get the instance of the SqlMapper defined by the SqlMap.Config file. | |
60 | /// </summary> | |
61 | /// <returns>A SqlMapper initalized via the SqlMap.Config file.</returns> | |
62 | 0 | public static SqlMapper Instance() |
63 | { | |
64 | if (_mapper == null) | |
65 | { | |
66 | lock (typeof (SqlMapper)) | |
67 | { | |
68 | if (_mapper == null) // double-check | |
69 | InitMapper(); | |
70 | } | |
71 | } | |
72 | return _mapper; | |
73 | } | |
74 | ||
75 | /// <summary> | |
76 | /// Get the instance of the SqlMapper defined by the SqlMap.Config file. (Convenience form of Instance method.) | |
77 | /// </summary> | |
78 | /// <returns>A SqlMapper initalized via the SqlMap.Config file.</returns> | |
79 | 0 | public static SqlMapper Get() |
80 | { | |
81 | return Instance(); | |
82 | } | |
83 | } | |
84 | } | |
85 |
|