1
- using System . Collections ;
2
- using System . Reflection ;
3
- using NHibernate . Engine ;
4
1
using System ;
2
+ using System . Collections ;
5
3
using System . Collections . Concurrent ;
6
4
using System . Collections . Generic ;
5
+ using System . Reflection ;
7
6
using System . Runtime . CompilerServices ;
8
7
using Microsoft . CSharp . RuntimeBinder ;
8
+ using NHibernate . Engine ;
9
9
using Binder = Microsoft . CSharp . RuntimeBinder . Binder ;
10
10
11
11
namespace NHibernate . Properties
12
12
{
13
13
[ Serializable ]
14
14
public class MapAccessor : IPropertyAccessor
15
- {
16
- public IGetter GetGetter ( System . Type theClass , string propertyName ) => new MapGetter ( propertyName ) ;
15
+ {
16
+ public IGetter GetGetter ( System . Type theClass , string propertyName )
17
+ {
18
+ return new MapGetter ( propertyName ) ;
19
+ }
17
20
18
- public ISetter GetSetter ( System . Type theClass , string propertyName ) => new MapSetter ( propertyName ) ;
21
+ public ISetter GetSetter ( System . Type theClass , string propertyName )
22
+ {
23
+ return new MapSetter ( propertyName ) ;
24
+ }
19
25
20
26
public bool CanAccessThroughReflectionOptimizer => false ;
21
27
22
28
[ Serializable ]
23
29
public sealed class MapSetter : ISetter
24
30
{
25
- private static readonly ConcurrentDictionary < Tuple < System . Type , string > , CallSite < Func < CallSite , object , object , object > > > SetMemberSites =
26
- new ConcurrentDictionary < Tuple < System . Type , string > , CallSite < Func < CallSite , object , object , object > > > ( ) ;
31
+ private static readonly ConcurrentDictionary < Tuple < System . Type , string > , CallSite < Func < CallSite , object , object , object > > >
32
+ SetMemberSites = new ConcurrentDictionary < Tuple < System . Type , string > , CallSite < Func < CallSite , object , object , object > > > ( ) ;
27
33
28
- private readonly string _name ;
34
+ private readonly string name ;
29
35
30
- internal MapSetter ( string name ) => _name = name ;
36
+ internal MapSetter ( string name )
37
+ {
38
+ this . name = name ;
39
+ }
31
40
32
41
public MethodInfo Method => null ;
33
42
@@ -38,14 +47,14 @@ public void Set(object target, object value)
38
47
switch ( target )
39
48
{
40
49
case IDictionary d :
41
- d [ _name ] = value ;
50
+ d [ name ] = value ;
42
51
break ;
43
52
case IDictionary < string , object > d :
44
- d [ _name ] = value ;
53
+ d [ name ] = value ;
45
54
break ;
46
55
default :
47
56
var site = SetMemberSites . GetOrAdd (
48
- System . Tuple . Create ( target . GetType ( ) , _name ) ,
57
+ System . Tuple . Create ( target . GetType ( ) , name ) ,
49
58
t => CallSite < Func < CallSite , object , object , object > > . Create (
50
59
Binder . GetMember (
51
60
CSharpBinderFlags . None ,
@@ -62,44 +71,50 @@ public void Set(object target, object value)
62
71
}
63
72
}
64
73
}
65
-
74
+
66
75
[ Serializable ]
67
76
public sealed class MapGetter : IGetter
68
77
{
69
- private static readonly ConcurrentDictionary < Tuple < System . Type , string > , CallSite < Func < CallSite , object , object > > > GetMemberSites =
70
- new ConcurrentDictionary < Tuple < System . Type , string > , CallSite < Func < CallSite , object , object > > > ( ) ;
78
+ private static readonly ConcurrentDictionary < Tuple < System . Type , string > , CallSite < Func < CallSite , object , object > > >
79
+ GetMemberSites = new ConcurrentDictionary < Tuple < System . Type , string > , CallSite < Func < CallSite , object , object > > > ( ) ;
71
80
72
- private readonly string _name ;
81
+ private readonly string name ;
73
82
74
- internal MapGetter ( string name ) => _name = name ;
83
+ internal MapGetter ( string name )
84
+ {
85
+ this . name = name ;
86
+ }
75
87
76
88
public MethodInfo Method => null ;
77
89
78
90
public string PropertyName => null ;
79
91
80
92
public System . Type ReturnType => typeof ( object ) ;
81
93
82
- public object GetForInsert ( object owner , IDictionary mergeMap , ISessionImplementor session ) => Get ( owner ) ;
94
+ public object GetForInsert ( object owner , IDictionary mergeMap , ISessionImplementor session )
95
+ {
96
+ return Get ( owner ) ;
97
+ }
83
98
84
99
public object Get ( object target )
85
100
{
86
101
switch ( target )
87
102
{
88
103
case IDictionary d :
89
- return d [ _name ] ;
104
+ return d [ name ] ;
90
105
case IDictionary < string , object > d :
91
- d . TryGetValue ( _name , out var result ) ;
106
+ d . TryGetValue ( name , out var result ) ;
92
107
return result ;
93
108
default :
94
109
var site = GetMemberSites . GetOrAdd (
95
- System . Tuple . Create ( target . GetType ( ) , _name ) ,
110
+ System . Tuple . Create ( target . GetType ( ) , name ) ,
96
111
t => CallSite < Func < CallSite , object , object > > . Create (
97
112
Binder . GetMember (
98
113
CSharpBinderFlags . None ,
99
114
t . Item2 ,
100
115
t . Item1 ,
101
116
new [ ] { CSharpArgumentInfo . Create ( CSharpArgumentInfoFlags . None , null ) } ) ) ) ;
102
-
117
+
103
118
return site . Target ( site , target ) ;
104
119
}
105
120
}
0 commit comments