| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
TypeHandlers\StringTypeHandler.cs | 100.0 % | 90.0 % | 80.0 % | 89.5 % |
|
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 | * | |
12 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
13 | * you may not use this file except in compliance with the License. | |
14 | * You may obtain a copy of the License at | |
15 | * | |
16 | * http://www.apache.org/licenses/LICENSE-2.0 | |
17 | * | |
18 | * Unless required by applicable law or agreed to in writing, software | |
19 | * distributed under the License is distributed on an "AS IS" BASIS, | |
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
21 | * See the License for the specific language governing permissions and | |
22 | * limitations under the License. | |
23 | * | |
24 | ********************************************************************************/ | |
25 | #endregion | |
26 | ||
27 | #region Using | |
28 | ||
29 | using System; | |
30 | using System.Data; | |
31 | using System.Globalization; | |
32 | ||
33 | using IBatisNet.DataMapper.Configuration.ResultMapping; | |
34 | #endregion | |
35 | ||
36 | ||
37 | ||
38 | namespace IBatisNet.DataMapper.TypeHandlers | |
39 | { | |
40 | /// <summary> | |
41 | /// Description résumée de SByteTypeHandler. | |
42 | /// </summary> | |
43 | internal class StringTypeHandler : BaseTypeHandler | |
44 | { | |
45 | ||
46 | /// <summary> | |
47 | /// | |
48 | /// </summary> | |
49 | /// <param name="mapping"></param> | |
50 | /// <param name="dataReader"></param> | |
51 | /// <returns></returns> | |
52 | 996 | public override object GetValueByName(ResultProperty mapping, IDataReader dataReader) |
53 | { | |
54 | 996 | int index = dataReader.GetOrdinal(mapping.ColumnName); |
55 | ||
56 | 996 | if (dataReader.IsDBNull(index) == true) |
57 | { | |
58 | 85 | return System.DBNull.Value; |
59 | } | |
60 | else | |
61 | { | |
62 | 911 | return dataReader.GetString(index); |
63 | } | |
64 | } | |
65 | ||
66 | /// <summary> | |
67 | /// | |
68 | /// </summary> | |
69 | /// <param name="mapping"></param> | |
70 | /// <param name="dataReader"></param> | |
71 | /// <returns></returns> | |
72 | 104 | public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader) |
73 | { | |
74 | 104 | if (dataReader.IsDBNull(mapping.ColumnIndex) == true) |
75 | { | |
76 | 7 | return System.DBNull.Value; |
77 | } | |
78 | else | |
79 | { | |
80 | 97 | return dataReader.GetString(mapping.ColumnIndex); |
81 | } | |
82 | } | |
83 | ||
84 | 0 | public override object GetDataBaseValue(object outputValue, Type parameterType ) |
85 | { | |
86 | return outputValue; | |
87 | } | |
88 | ||
89 | 67 | public override object ValueOf(Type type, string s) |
90 | { | |
91 | 67 | return s; |
92 | } | |
93 | ||
94 | ||
95 | /// <summary> | |
96 | /// | |
97 | /// </summary> | |
98 | /// <returns></returns> | |
99 | public override bool IsSimpleType | |
100 | { | |
101 | 11 | get |
102 | { | |
103 | 11 | return true; |
104 | } | |
105 | } | |
106 | } | |
107 | } | |
108 |
|