Clover.NET coverage report - Coverage for s2container.net

Coverage timestamp: 2006年5月30日 11:21:29

File Stats: LOC: 167   Methods: 7
NCLOC: 139 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Extension.DataSets.Types\ColumnTypes.cs 50.0% 86.8% 71.4% 83.5%
coverage coverage
1   #region Copyright
2   /*
3   * Copyright 2005 the Seasar Foundation and the Others.
4   *
5   * Licensed under the Apache License, Version 2.0 (the "License");
6   * you may not use this file except in compliance with the License.
7   * You may obtain a copy of the License at
8   *
9   * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14   * either express or implied. See the License for the specific language
15   * governing permissions and limitations under the License.
16   */
17   #endregion
18  
19   using System;
20   using System.Collections;
21   using System.Data;
22   using System.Data.SqlTypes;
23   using Seasar.Extension.ADO;
24   using Seasar.Extension.ADO.Types;
25   using Nullables;
26  
27   namespace Seasar.Extension.DataSets.Types
28   {
29   public sealed class ColumnTypes
30   {
31   public static readonly IColumnType STRING = new StringType();
32   public static readonly IColumnType DECIMAL = new DecimalType();
33   public static readonly IColumnType DATETIME = new DateTimeType();
34   public static readonly IColumnType BINARY = new BinaryType();
35   public static readonly IColumnType BOOLEAN = new BooleanType();
36   public static readonly IColumnType OBJECT = new ObjectType();
37   private static Hashtable types_ = new Hashtable();
38  
39 1 static ColumnTypes()
40   {
41 1 RegisterColumnType(typeof(String), STRING);
42 1 RegisterColumnType(typeof(Byte), DECIMAL);
43 1 RegisterColumnType(typeof(SByte), DECIMAL);
44 1 RegisterColumnType(typeof(Int16), DECIMAL);
45 1 RegisterColumnType(typeof(Int32), DECIMAL);
46 1 RegisterColumnType(typeof(Int64), DECIMAL);
47 1 RegisterColumnType(typeof(Single), DECIMAL);
48 1 RegisterColumnType(typeof(Double), DECIMAL);
49 1 RegisterColumnType(typeof(Decimal), DECIMAL);
50 1 RegisterColumnType(typeof(DateTime), DATETIME);
51 1 RegisterColumnType(ValueTypes.BYTE_ARRAY_TYPE, BINARY);
52 1 RegisterColumnType(typeof(Boolean), BOOLEAN);
53 1 RegisterColumnType(typeof(Guid), OBJECT);
54  
55 1 RegisterColumnType(typeof(SqlString), STRING);
56 1 RegisterColumnType(typeof(SqlByte), DECIMAL);
57 1 RegisterColumnType(typeof(SqlInt16), DECIMAL);
58 1 RegisterColumnType(typeof(SqlInt32), DECIMAL);
59 1 RegisterColumnType(typeof(SqlInt64), DECIMAL);
60 1 RegisterColumnType(typeof(SqlSingle), DECIMAL);
61 1 RegisterColumnType(typeof(SqlDouble), DECIMAL);
62 1 RegisterColumnType(typeof(SqlDecimal), DECIMAL);
63 1 RegisterColumnType(typeof(SqlDateTime), DATETIME);
64 1 RegisterColumnType(typeof(SqlBinary), BINARY);
65 1 RegisterColumnType(typeof(SqlBoolean), BOOLEAN);
66 1 RegisterColumnType(typeof(SqlMoney), DECIMAL);
67 1 RegisterColumnType(typeof(SqlGuid), OBJECT);
68  
69 1 RegisterColumnType(typeof(NullableChar), STRING);
70 1 RegisterColumnType(typeof(NullableByte), DECIMAL);
71 1 RegisterColumnType(typeof(NullableSByte), DECIMAL);
72 1 RegisterColumnType(typeof(NullableInt16), DECIMAL);
73 1 RegisterColumnType(typeof(NullableInt32), DECIMAL);
74 1 RegisterColumnType(typeof(NullableInt64), DECIMAL);
75 1 RegisterColumnType(typeof(NullableSingle), DECIMAL);
76 1 RegisterColumnType(typeof(NullableDouble), DECIMAL);
77 1 RegisterColumnType(typeof(NullableDecimal), DECIMAL);
78 1 RegisterColumnType(typeof(NullableDateTime), DATETIME);
79 1 RegisterColumnType(ValueTypes.NHIBERNATE_NULLABLE_BYTE_ARRAY_TYPE, BINARY);
80 1 RegisterColumnType(typeof(NullableBoolean), BOOLEAN);
81 1 RegisterColumnType(typeof(NullableGuid), OBJECT);
82  
83 1 RegisterColumnType(typeof(Nullable<Byte>), DECIMAL);
84 1 RegisterColumnType(typeof(Nullable<SByte>), DECIMAL);
85 1 RegisterColumnType(typeof(Nullable<Int16>), DECIMAL);
86 1 RegisterColumnType(typeof(Nullable<Int32>), DECIMAL);
87 1 RegisterColumnType(typeof(Nullable<Int64>), DECIMAL);
88 1 RegisterColumnType(typeof(Nullable<Single>), DECIMAL);
89 1 RegisterColumnType(typeof(Nullable<Double>), DECIMAL);
90 1 RegisterColumnType(typeof(Nullable<Decimal>), DECIMAL);
91 1 RegisterColumnType(typeof(Nullable<DateTime>), DATETIME);
92 1 RegisterColumnType(ValueTypes.NULLABLE_BYTE_ARRAY_TYPE, BINARY);
93 1 RegisterColumnType(typeof(Nullable<Boolean>), BOOLEAN);
94   }
95  
96 0 private ColumnTypes()
97   {
98   }
99  
100 50 public static void RegisterColumnType(Type type, IColumnType columnType)
101   {
102 50 lock (types_)
103   {
104 50 types_[type] = columnType;
105   }
106   }
107  
108 0 public static IColumnType GetColumnType(DbType type)
109   {
110   switch (type)
111   {
112   case DbType.Byte :
113   case DbType.SByte :
114   case DbType.Int16 :
115   case DbType.Int32 :
116   case DbType.Int64 :
117   case DbType.Single :
118   case DbType.Double :
119   case DbType.Decimal :
120   case DbType.VarNumeric :
121   return DECIMAL;
122   case DbType.Boolean :
123   return BOOLEAN;
124   case DbType.Date :
125   case DbType.Time :
126   case DbType.DateTime :
127   return DATETIME;
128   case DbType.Binary :
129   return BINARY;
130   case DbType.String :
131   case DbType.StringFixedLength :
132   return STRING;
133   case DbType.Guid :
134   default:
135   return OBJECT;
136   }
137   }
138  
139 26 public static IColumnType GetColumnType(object value)
140   {
141 26 if (value == null)
142   {
143 0 return OBJECT;
144   }
145 26 return GetColumnType(value.GetType());
146   }
147  
148 475 public static IColumnType GetColumnType(Type type)
149   {
150 475 IColumnType columnType = GetColumnType0(type);
151 475 if (columnType != null)
152   {
153 475 return columnType;
154   }
155 0 return OBJECT;
156   }
157  
158 475 private static IColumnType GetColumnType0(Type type)
159   {
160 475 lock (types_)
161   {
162 475 return (IColumnType) types_[type];
163   }
164   }
165   }
166   }
167