• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / EntityChange / 10792597827

10 Sep 2024 12:38PM UTC coverage: 39.608%. Remained the same
10792597827

push

github

web-flow
Merge pull request #103 from loresoft/dependabot/nuget/MinVer-6.0.0

Bump MinVer from 5.0.0 to 6.0.0

237 of 731 branches covered (32.42%)

Branch coverage included in aggregate %.

571 of 1309 relevant lines covered (43.62%)

60.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/EntityChange/Reflection/MethodAccessor.cs
1
using System.Diagnostics;
2
using System.Reflection;
3

4
namespace EntityChange.Reflection;
5

6
/// <summary>
7
/// An accessor class for <see cref="MethodInfo"/>.
8
/// </summary>
9
[DebuggerDisplay("Name: {Name}")]
10
public class MethodAccessor : IMethodAccessor
11
{
12
    private readonly Lazy<Func<object, object[], object>> _invoker;
13

14
    /// <summary>
15
    /// Initializes a new instance of the <see cref="MethodAccessor"/> class.
16
    /// </summary>
17
    /// <param name="methodInfo">The method info.</param>
18
    public MethodAccessor(MethodInfo methodInfo)
×
19
    {
20
        if (methodInfo == null)
×
21
            throw new ArgumentNullException(nameof(methodInfo));
×
22

23
        MethodInfo = methodInfo;
×
24
        Name = methodInfo.Name;
×
25
        _invoker = new Lazy<Func<object, object[], object>>(() => ExpressionFactory.CreateMethod(MethodInfo));
×
26
    }
×
27

28
    /// <summary>
29
    /// Gets the method info.
30
    /// </summary>
31
    public MethodInfo MethodInfo { get; }
×
32

33
    /// <summary>
34
    /// Gets the name of the member.
35
    /// </summary>
36
    /// <value>
37
    /// The name of the member.
38
    /// </value>
39
    public string Name { get; }
×
40

41
    /// <summary>
42
    /// Invokes the method on the specified <paramref name="instance"/>.
43
    /// </summary>
44
    /// <param name="instance">The object on which to invoke the method. If a method is static, this argument is ignored.</param>
45
    /// <param name="arguments">An argument list for the invoked method.</param>
46
    /// <returns>
47
    /// An object containing the return value of the invoked method.
48
    /// </returns>
49
    public object Invoke(object instance, params object[] arguments)
50
    {
51
        return _invoker.Value.Invoke(instance, arguments);
×
52
    }
53

54
    /// <summary>
55
    /// Gets the method key using a hash code from the name and paremeter types.
56
    /// </summary>
57
    /// <param name="name">The name of the method.</param>
58
    /// <param name="parameterTypes">The method parameter types.</param>
59
    /// <returns>The method key</returns>
60
    internal static int GetKey(string name, IEnumerable<Type> parameterTypes)
61
    {
62
        unchecked
63
        {
64
            int result = name?.GetHashCode() ?? 0;
×
65
            result = parameterTypes.Aggregate(result,
×
66
              (r, p) => (r * 397) ^ (p?.GetHashCode() ?? 0));
×
67

68
            return result;
×
69
        }
70
    }
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc