From 28d76f4bf02d839fe2197b6ac881979b06bc1b1f Mon Sep 17 00:00:00 2001 From: lindexi Date: Fri, 5 Jan 2024 15:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=8F=E5=B0=91=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=87=8F=E5=B0=91=20JIT=20=E5=8E=8B=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Json_/JsonIpcDirectRoutedProvider.cs | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/dotnetCampus.Ipc/IpcRouteds/DirectRouteds/Json_/JsonIpcDirectRoutedProvider.cs b/src/dotnetCampus.Ipc/IpcRouteds/DirectRouteds/Json_/JsonIpcDirectRoutedProvider.cs index 30d6d91..4c18d34 100644 --- a/src/dotnetCampus.Ipc/IpcRouteds/DirectRouteds/Json_/JsonIpcDirectRoutedProvider.cs +++ b/src/dotnetCampus.Ipc/IpcRouteds/DirectRouteds/Json_/JsonIpcDirectRoutedProvider.cs @@ -91,7 +91,13 @@ public void AddNotifyHandler(string routedPath, Func handler) /// public void AddNotifyHandler(string routedPath, Func handler) { - AddNotifyHandler(routedPath, CreateHandleNotify(handler)); + Task HandleNotify(MemoryStream stream, JsonIpcDirectRoutedContext context) + { + var argument = ToObject(stream); + return handler(argument!, context); + } + + AddNotifyHandler(routedPath, new NotifyHandler() { AsyncHandler = HandleNotify }); } /// @@ -114,7 +120,13 @@ public void AddNotifyHandler(string routedPath, Action handler) /// public void AddNotifyHandler(string routedPath, Action handler) { - AddNotifyHandler(routedPath, CreateHandleNotify(handler)); + void HandleNotify(MemoryStream stream, JsonIpcDirectRoutedContext context) + { + var argument = ToObject(stream); + handler(argument!, context); + } + + AddNotifyHandler(routedPath, new NotifyHandler() { SyncHandler = HandleNotify }); } private void AddNotifyHandler(string routedPath, NotifyHandler notifyHandler) @@ -133,28 +145,6 @@ private class NotifyHandler public Action? SyncHandler { get; set; } } - private NotifyHandler CreateHandleNotify(Action handler) - { - void HandleNotify(MemoryStream stream, JsonIpcDirectRoutedContext context) - { - var argument = ToObject(stream); - handler(argument!, context); - } - - return new NotifyHandler() { SyncHandler = HandleNotify }; - } - - private NotifyHandler CreateHandleNotify(Func handler) - { - Task HandleNotify(MemoryStream stream, JsonIpcDirectRoutedContext context) - { - var argument = ToObject(stream); - return handler(argument!, context); - } - - return new NotifyHandler() { AsyncHandler = HandleNotify }; - } - private ConcurrentDictionary HandleNotifyDictionary { get; } = new ConcurrentDictionary();