diff --git a/Source/Orleankka.Runtime/InvokeMethodRequestExtensions.cs b/Source/Orleankka.Runtime/InvokeMethodRequestExtensions.cs index 255f6e4c..ba0614ad 100644 --- a/Source/Orleankka.Runtime/InvokeMethodRequestExtensions.cs +++ b/Source/Orleankka.Runtime/InvokeMethodRequestExtensions.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using Orleans.CodeGeneration; using Orleans.Concurrency; @@ -8,13 +7,8 @@ namespace Orleankka { public static class InvokeMethodRequestExtensions { - public static bool Any(this InvokeMethodRequest request, params Type[] messages) - { - var message = request.Message().GetType(); - return messages.Any(x => x == message); - } - - public static T Message(this InvokeMethodRequest request) => (T) request.Message(); + public static bool Message(this InvokeMethodRequest request, Func predicate) => + predicate(request.Message()); public static object Message(this InvokeMethodRequest request) { @@ -30,6 +24,6 @@ public static object Message(this InvokeMethodRequest request) } static object UnwrapImmutable(object item) => - item is Immutable ? ((Immutable)item).Value : item; + item is Immutable immutable ? immutable.Value : item; } } \ No newline at end of file diff --git a/Tests/Orleankka.Tests/Features/Reentrant_messages.cs b/Tests/Orleankka.Tests/Features/Reentrant_messages.cs index f16681c3..35a089b0 100644 --- a/Tests/Orleankka.Tests/Features/Reentrant_messages.cs +++ b/Tests/Orleankka.Tests/Features/Reentrant_messages.cs @@ -75,9 +75,8 @@ public interface ITestReentrantStreamConsumerActor : IActorGrain [MayInterleave(nameof(Interleave))] public class TestReentrantStreamConsumerActor : DispatchActorGrain, ITestReentrantStreamConsumerActor { - public static bool Interleave(InvokeMethodRequest req) => req.Any( - typeof(GetStreamMessagesInProgress), - typeof(int)); // 1-st stream message type + public static bool Interleave(InvokeMethodRequest req) => + req.Message(x => x is GetStreamMessagesInProgress || x is int); // int is 1-st stream message type readonly List streamMessagesInProgress = new List(); List On(GetStreamMessagesInProgress x) => streamMessagesInProgress;