Clover.NET coverage report - Coverage for s2dao.net

Coverage timestamp: 2006年5月30日 11:48:56

File Stats: LOC: 115   Methods: 11
NCLOC: 82 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Dao.Impl\DtoMetaDataImpl.cs 83.3% 76.0% 81.8% 78.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.Collections;
21   using System.Reflection;
22   using Seasar.Dao.Attrs;
23   using Seasar.Extension.ADO;
24   using Seasar.Extension.ADO.Impl;
25   using Seasar.Extension.ADO.Types;
26   using Seasar.Framework.Beans;
27  
28   namespace Seasar.Dao.Impl
29   {
30   public class DtoMetaDataImpl : IDtoMetaData
31   {
32   private Type beanType;
33   private Hashtable propertyTypes = new Hashtable(
34   CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
35  
36 62 protected DtoMetaDataImpl()
37   {
38   }
39  
40 0 public DtoMetaDataImpl(Type beanType)
41   {
42   this.beanType = beanType;
43   SetupPropertyType();
44   }
45  
46   #region IDtoMetaData メンバ
47  
48   public Type BeanType
49   {
50 120 get
51   {
52 120 return beanType;
53   }
54 62 set
55   {
56 62 beanType = value;
57   }
58   }
59  
60   public int PropertyTypeSize
61   {
62 4255 get
63   {
64 4255 return propertyTypes.Count;
65   }
66   }
67  
68 3747 public Seasar.Extension.ADO.IPropertyType GetPropertyType(int index)
69   {
70 3747 IEnumerator enu = propertyTypes.Keys.GetEnumerator();
71 16876 for(int i = -1; i < index; ++i) enu.MoveNext();
72 3747 return (IPropertyType) propertyTypes[enu.Current];
73   }
74  
75 282 public IPropertyType GetPropertyType(string propertyName)
76   {
77 282 IPropertyType propertyType = (IPropertyType) propertyTypes[propertyName];
78 282 if(propertyType == null)
79 0 throw new PropertyNotFoundRuntimeException(beanType, propertyName);
80 282 return propertyType;
81   }
82  
83 256 public bool HasPropertyType(string propertyName)
84   {
85 256 return propertyTypes.Contains(propertyName);
86   }
87  
88   #endregion
89  
90 0 protected void SetupPropertyType()
91   {
92   foreach(PropertyInfo pi in beanType.GetProperties())
93   {
94   IPropertyType pt = CreatePropertyType(pi);
95   AddPropertyType(pt);
96   }
97   }
98  
99 334 protected IPropertyType CreatePropertyType(PropertyInfo pi)
100   {
101 334 ColumnAttribute attr = AttributeUtil.GetColumnAttribute(pi);
102 334 string columnName = pi.Name;
103 334 if(attr != null) columnName = attr.ColumnName;
104 334 IValueType valueType = ValueTypes.GetValueType(pi.PropertyType);
105 334 IPropertyType pt = new PropertyTypeImpl(pi, valueType, columnName);
106 334 return pt;
107   }
108  
109 334 protected void AddPropertyType(IPropertyType propertyType)
110   {
111 334 propertyTypes.Add(propertyType.PropertyName, propertyType);
112   }
113   }
114   }
115