Skip to content

Commit

Permalink
Add overload to simplify matching in F#
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhen committed Dec 6, 2019
1 parent 6419439 commit f5e581e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Samples/FSharp/Reentrant/RealTimeCounter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 45,7 @@ type Counter() =
| _ -> return unhandled()
}

static member IsReentrant(req:InvokeMethodRequest) = req.Message(fun x -> x > GetCount)
static member IsReentrant(req:InvokeMethodRequest) = req.Message(fun x ->
match x with
| GetCount -> true
| _ -> false)
3 changes: 3 additions & 0 deletions Source/Orleankka.Runtime/InvokeMethodRequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 10,9 @@ public static class InvokeMethodRequestExtensions
public static bool Message(this InvokeMethodRequest request, Func<object, bool> predicate) =>
predicate(request.Message());

public static bool Message<T>(this InvokeMethodRequest request, Func<T, bool> predicate) =>
request.Message() is T m && predicate(m);

public static object Message(this InvokeMethodRequest request)
{
if (request?.Arguments == null)
Expand Down

0 comments on commit f5e581e

Please sign in to comment.