1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
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
|
|
|