Skip to content

Commit baa386f

Browse files
committed
Get rid of GetGenericMethodDefinition method call
1 parent 9bee10f commit baa386f

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

Orm/Xtensive.Orm/Modelling/PropertyAccessor.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace Xtensive.Modelling
1818
/// </summary>
1919
public sealed class PropertyAccessor
2020
{
21+
private static readonly MethodInfo InnerInitializeMethodDefinition;
22+
2123
private Func<object, object> getter;
2224
private Action<object, object> setter;
2325
[NonSerialized]
@@ -38,7 +40,7 @@ public sealed class PropertyAccessor
3840
private Type dependencyRootType;
3941

4042
/// <summary>
41-
/// Gets <see cref="System.Reflection.PropertyInfo"/> of property
43+
/// Gets <see cref="System.Reflection.PropertyInfo"/> of property
4244
/// this accessor is bound to.
4345
/// </summary>
4446
public PropertyInfo PropertyInfo { get; private set; }
@@ -81,7 +83,7 @@ public bool IsImmutable {
8183
}
8284

8385
/// <summary>
84-
/// Gets a value indicating whether underlying property must be
86+
/// Gets a value indicating whether underlying property must be
8587
/// ignored during recreation of parent atomic property.
8688
/// </summary>
8789
public bool IsVolatile {
@@ -92,7 +94,7 @@ public bool IsVolatile {
9294
/// Gets or sets a value indicating whether property owner should be recreated on property value change.
9395
/// </summary>
9496
public bool RecreateParent {
95-
get { return recreateParent; }
97+
get { return recreateParent; }
9698
}
9799

98100
/// <summary>
@@ -136,7 +138,7 @@ public Action<object, object> Setter {
136138
/// <summary>
137139
/// Gets the dependency root object.
138140
/// </summary>
139-
public IPathNode GetDependencyRoot(IPathNode source)
141+
public IPathNode GetDependencyRoot(IPathNode source)
140142
{
141143
if (source==null)
142144
return null;
@@ -172,12 +174,7 @@ private void Initialize()
172174
dependencyRootType = pa.DependencyRootType;
173175
compareCaseInsensitive = tProperty == WellKnownTypes.String && pa.CaseInsensitiveComparison;
174176
}
175-
this.GetType()
176-
.GetMethod("InnerInitialize",
177-
BindingFlags.Instance |
178-
BindingFlags.NonPublic,
179-
null, ArrayUtils<Type>.EmptyArray, null)
180-
.GetGenericMethodDefinition()
177+
InnerInitializeMethodDefinition
181178
.MakeGenericMethod(new[] {tType, tProperty})
182179
.Invoke(this, null);
183180
}
@@ -201,6 +198,17 @@ private void InnerInitialize<TType, TProperty>()
201198

202199
// Constructors
203200

201+
static PropertyAccessor()
202+
{
203+
InnerInitializeMethodDefinition = typeof(PropertyAccessor)
204+
.GetMethod(nameof(InnerInitialize),
205+
BindingFlags.Instance | BindingFlags.NonPublic,
206+
null,
207+
Array.Empty<Type>(),
208+
null)
209+
?.GetGenericMethodDefinition();
210+
}
211+
204212
/// <summary>
205213
/// Initializes new instance of this type.
206214
/// </summary>

0 commit comments

Comments
 (0)