Skip to content

Commit 727e828

Browse files
committed
Minor code refactoring and performance tweak
1 parent fb17f61 commit 727e828

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

Microsoft.Toolkit.Mvvm/Messaging/IMessengerExtensions.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,10 @@ public static class IMessengerExtensions
2727
/// </summary>
2828
private static class MethodInfos
2929
{
30-
/// <summary>
31-
/// Initializes static members of the <see cref="MethodInfos"/> class.
32-
/// </summary>
33-
static MethodInfos()
34-
{
35-
RegisterIRecipient = (
36-
from methodInfo in typeof(IMessengerExtensions).GetMethods()
37-
where methodInfo.Name == nameof(Register) &&
38-
methodInfo.IsGenericMethod &&
39-
methodInfo.GetGenericArguments().Length == 2
40-
let parameters = methodInfo.GetParameters()
41-
where parameters.Length == 3 &&
42-
parameters[1].ParameterType.IsGenericType &&
43-
parameters[1].ParameterType.GetGenericTypeDefinition() == typeof(IRecipient<>)
44-
select methodInfo).First();
45-
}
46-
4730
/// <summary>
4831
/// The <see cref="MethodInfo"/> instance associated with <see cref="Register{TMessage,TToken}(IMessenger,IRecipient{TMessage},TToken)"/>.
4932
/// </summary>
50-
public static readonly MethodInfo RegisterIRecipient;
33+
public static readonly MethodInfo RegisterIRecipient = new Action<IMessenger, IRecipient<object>, Unit>(Register).Method.GetGenericMethodDefinition();
5134
}
5235

5336
/// <summary>

0 commit comments

Comments
 (0)