Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 86   Methods: 5
NCLOC: 60 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Extension.ADO\Impl\AbstractBeanDataReaderHandler.cs 100.0% 95.2% 80.0% 93.3%
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 System.Reflection;
22   using Seasar.Extension.ADO.Types;
23   using Seasar.Framework.Util;
24  
25   namespace Seasar.Extension.ADO.Impl
26   {
27   public abstract class AbstractBeanDataReaderHandler : IDataReaderHandler
28   {
29   private Type beanType_;
30  
31 3 public AbstractBeanDataReaderHandler(Type beanType)
32   {
33 3 SetBeanType(beanType);
34   }
35  
36 0 public Type BeanType
37   {
38   get { return beanType_; }
39   }
40  
41 3 public void SetBeanType(Type beanType)
42   {
43 3 beanType_ = beanType;
44   }
45  
46 3 protected IPropertyType[] CreatePropertyTypes(DataTable metaData)
47   {
48 3 int count = metaData.Rows.Count;
49 3 IPropertyType[] propertyTypes = new PropertyTypeImpl[count];
50 23 for (int i = 0; i < count; ++i)
51   {
52 20 DataRow row = metaData.Rows[i];
53 20 string columnName = (string) row["ColumnName"];
54 20 string propertyName = columnName.Replace("_", "");
55 20 PropertyInfo pi = beanType_.GetProperty(
56   propertyName,
57   BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase
58   );
59 20 IValueType valueType = ValueTypes.GetValueType(pi.PropertyType);
60 20 propertyTypes[i] = new PropertyTypeImpl(pi, valueType, columnName);
61   }
62 3 return propertyTypes;
63   }
64  
65 16 protected object CreateRow(IDataReader dataReader, IPropertyType[] propertyTypes)
66   {
67 16 object row = ClassUtil.NewInstance(beanType_);
68 153 for (int i = 0; i < propertyTypes.Length; ++i)
69   {
70 137 IPropertyType pt = propertyTypes[i];
71 137 IValueType valueType = pt.ValueType;
72 137 object value = valueType.GetValue(dataReader, pt.ColumnName);
73 137 PropertyInfo pi = pt.PropertyInfo;
74 137 pi.SetValue(row, value, null);
75   }
76 16 return row;
77   }
78  
79   #region IDataReaderHandler メンバ
80  
81   public abstract object Handle(IDataReader dataReader);
82  
83   #endregion
84   }
85   }
86