Clover.NET coverage report - Coverage for s2dao.net

Coverage timestamp: 2006年5月18日 15:09:15

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 44 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 104 get
51   {
52 104 return beanType;
53   }
54 44 set
55   {
56 44 beanType = value;
57   }
58   }
59  
60   public int PropertyTypeSize
61   {
62 3295 get
63   {
64 3295 return propertyTypes.Count;
65   }
66   }
67  
68 2916 public Seasar.Extension.ADO.IPropertyType GetPropertyType(int index)
69   {
70 2916 IEnumerator enu = propertyTypes.Keys.GetEnumerator();
71 13449 for(int i = -1; i < index; ++i) enu.MoveNext();
72 2916 return (IPropertyType) propertyTypes[enu.Current];
73   }
74  
75 261 public IPropertyType GetPropertyType(string propertyName)
76   {
77 261 IPropertyType propertyType = (IPropertyType) propertyTypes[propertyName];
78 261 if(propertyType == null)
79 0 throw new PropertyNotFoundRuntimeException(beanType, propertyName);
80 261 return propertyType;
81   }
82  
83 216 public bool HasPropertyType(string propertyName)
84   {
85 216 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 244 protected IPropertyType CreatePropertyType(PropertyInfo pi)
100   {
101 244 ColumnAttribute attr = AttributeUtil.GetColumnAttribute(pi);
102 244 string columnName = pi.Name;
103 244 if(attr != null) columnName = attr.ColumnName;
104 244 IValueType valueType = ValueTypes.GetValueType(pi.PropertyType);
105 244 IPropertyType pt = new PropertyTypeImpl(pi, valueType, columnName);
106 244 return pt;
107   }
108  
109 244 protected void AddPropertyType(IPropertyType propertyType)
110   {
111 244 propertyTypes.Add(propertyType.PropertyName, propertyType);
112   }
113   }
114   }
115