Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 99   Methods: 5
NCLOC: 74 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Extension.DataSets\Impl\DataTableDataReaderHandler.cs 85.7% 96.4% 100.0% 93.6%
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.Data;
21   using Seasar.Extension.ADO;
22   using Seasar.Extension.ADO.Impl;
23   using Seasar.Extension.DataSets.Types;
24   using Seasar.Framework.Util;
25  
26   namespace Seasar.Extension.DataSets.Impl
27   {
28   public class DataTableDataReaderHandler : IDataReaderHandler
29   {
30   private string tableName_;
31  
32 10 public DataTableDataReaderHandler(string tableName)
33   {
34 10 tableName_ = tableName;
35   }
36  
37   #region IDataReaderHandler メンバ
38  
39 10 public object Handle(System.Data.IDataReader reader)
40   {
41 10 IPropertyType[] propertyTypes = PropertyTypeUtil.CreatePropertyTypes(reader.GetSchemaTable());
42 10 DataTable table = new DataTable(tableName_);
43 88 for (int i = 0; i < propertyTypes.Length; ++i)
44   {
45 78 String propertyName = propertyTypes[i].PropertyName;
46 78 Type type = ColumnTypes.GetColumnType(propertyTypes[i].PropertyType).GetColumnType();
47 78 table.Columns.Add(propertyName, type);
48   }
49 44 while (reader.Read())
50   {
51 34 AddRow(reader, propertyTypes, table);
52   }
53 10 return table;
54   }
55  
56   #endregion
57  
58 34 private void AddRow(System.Data.IDataReader reader, IPropertyType[] propertyTypes, DataTable table)
59   {
60 34 DataRow row = table.NewRow();
61 328 for (int i = 0; i < table.Columns.Count; ++i)
62   {
63 294 row[i] = GetValue(reader, i, propertyTypes);
64   }
65 34 table.Rows.Add(row);
66   }
67  
68 294 private object GetValue(System.Data.IDataReader reader, int index, IPropertyType[] propertyTypes)
69   {
70 294 Type type = propertyTypes[index].PropertyType;
71 294 object value = propertyTypes[index].ValueType.GetValue(reader, index);
72 294 if (value == null)
73   {
74 32 return DBNull.Value;
75   }
76 262 object ret = ColumnTypes.GetColumnType(type).Convert(value, null);
77 262 if (ret is string)
78   {
79 67 string s = ret as string;
80 67 if (s != null)
81   {
82 67 s = s.TrimEnd(null);
83   }
84 67 if (IsCellBase64Formatted(s))
85   {
86 0 return Convert.FromBase64String(s);
87   }
88 67 return s;
89   }
90 195 return ret;
91   }
92  
93 67 private bool IsCellBase64Formatted(string s)
94   {
95 67 return DataSetConstants.BASE64_FORMAT.StartsWith(s);
96   }
97   }
98   }
99