Skip to content

Commit f650789

Browse files
committed
Code cleanup
1 parent 97fe732 commit f650789

File tree

4 files changed

+41
-26
lines changed

4 files changed

+41
-26
lines changed

src/NHibernate.Test/NHSpecificTest/NH2664Dynamic/Fixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ public void Multiple_Query_Does_Not_Cache()
103103
}
104104
}
105105
}
106-
}
106+
}

src/NHibernate.Test/NHSpecificTest/NH2664Dynamic/Mappings.hbm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
</class>
1616

17-
</hibernate-mapping>
17+
</hibernate-mapping>

src/NHibernate.Test/NHSpecificTest/NH2664Dynamic/Product.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ public class Product
66

77
public virtual dynamic Properties { get; set; }
88
}
9-
}
9+
}

src/NHibernate/Properties/MapAccessor.cs

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
1-
using System.Collections;
2-
using System.Reflection;
3-
using NHibernate.Engine;
41
using System;
2+
using System.Collections;
53
using System.Collections.Concurrent;
64
using System.Collections.Generic;
5+
using System.Reflection;
76
using System.Runtime.CompilerServices;
87
using Microsoft.CSharp.RuntimeBinder;
8+
using NHibernate.Engine;
99
using Binder = Microsoft.CSharp.RuntimeBinder.Binder;
1010

1111
namespace NHibernate.Properties
1212
{
1313
[Serializable]
1414
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+
}
1720

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+
}
1925

2026
public bool CanAccessThroughReflectionOptimizer => false;
2127

2228
[Serializable]
2329
public sealed class MapSetter : ISetter
2430
{
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>>>();
2733

28-
private readonly string _name;
34+
private readonly string name;
2935

30-
internal MapSetter(string name) => _name = name;
36+
internal MapSetter(string name)
37+
{
38+
this.name = name;
39+
}
3140

3241
public MethodInfo Method => null;
3342

@@ -38,14 +47,14 @@ public void Set(object target, object value)
3847
switch (target)
3948
{
4049
case IDictionary d:
41-
d[_name] = value;
50+
d[name] = value;
4251
break;
4352
case IDictionary<string, object> d:
44-
d[_name] = value;
53+
d[name] = value;
4554
break;
4655
default:
4756
var site = SetMemberSites.GetOrAdd(
48-
System.Tuple.Create(target.GetType(), _name),
57+
System.Tuple.Create(target.GetType(), name),
4958
t => CallSite<Func<CallSite, object, object, object>>.Create(
5059
Binder.GetMember(
5160
CSharpBinderFlags.None,
@@ -62,44 +71,50 @@ public void Set(object target, object value)
6271
}
6372
}
6473
}
65-
74+
6675
[Serializable]
6776
public sealed class MapGetter : IGetter
6877
{
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>>>();
7180

72-
private readonly string _name;
81+
private readonly string name;
7382

74-
internal MapGetter(string name) => _name = name;
83+
internal MapGetter(string name)
84+
{
85+
this.name = name;
86+
}
7587

7688
public MethodInfo Method => null;
7789

7890
public string PropertyName => null;
7991

8092
public System.Type ReturnType => typeof(object);
8193

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+
}
8398

8499
public object Get(object target)
85100
{
86101
switch (target)
87102
{
88103
case IDictionary d:
89-
return d[_name];
104+
return d[name];
90105
case IDictionary<string, object> d:
91-
d.TryGetValue(_name, out var result);
106+
d.TryGetValue(name, out var result);
92107
return result;
93108
default:
94109
var site = GetMemberSites.GetOrAdd(
95-
System.Tuple.Create(target.GetType(), _name),
110+
System.Tuple.Create(target.GetType(), name),
96111
t => CallSite<Func<CallSite, object, object>>.Create(
97112
Binder.GetMember(
98113
CSharpBinderFlags.None,
99114
t.Item2,
100115
t.Item1,
101116
new[] {CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)})));
102-
117+
103118
return site.Target(site, target);
104119
}
105120
}

0 commit comments

Comments
 (0)