Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 89   Methods: 3
NCLOC: 67 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Util\PropertyUtil.cs 100.0% 100.0% 66.7% 97.7%
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.SqlTypes;
21   using System.Reflection;
22   using Nullables;
23  
24   namespace Seasar.Framework.Util
25   {
26   public sealed class PropertyUtil
27   {
28 0 private PropertyUtil()
29   {
30   }
31  
32 179 public static Type GetPrimitiveType(Type type)
33   {
34 179 if (type.GetInterface(typeof(INullableType).Name) != null)
35   {
36 44 ConstructorInfo[] constructorInfos = type.GetConstructors();
37 44 ParameterInfo[] parameterInfos = constructorInfos[0].GetParameters();
38 44 type = parameterInfos[0].ParameterType;
39   }
40 135 else if (type.GetInterface(typeof(INullable).Name) != null)
41   {
42 48 PropertyInfo npi = type.GetProperty("Value");
43 48 return npi.PropertyType;
44   }
45 87 else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
46   {
47 22 type = Nullable.GetUnderlyingType(type);
48   }
49 131 return type;
50   }
51  
52 180 public static object GetPrimitiveValue(object value)
53   {
54 180 if (value == null || value == DBNull.Value)
55   {
56 14 return DBNull.Value;
57   }
58  
59 166 if (value is INullableType)
60   {
61 44 INullableType nullableType = (INullableType) value;
62 44 if (nullableType.HasValue)
63   {
64 22 return nullableType.Value;
65   }
66   else
67   {
68 22 return DBNull.Value;
69   }
70   }
71 122 else if (value is INullable)
72   {
73 48 INullable nullable = (INullable) value;
74 48 if (!nullable.IsNull)
75   {
76 26 PropertyInfo npi = value.GetType().GetProperty("Value");
77 26 return npi.GetValue(value, null);
78   }
79   else
80   {
81 22 return DBNull.Value;
82   }
83   }
84  
85 74 return value;
86   }
87   }
88   }
89