From 165f573465451a484d7de20719c40fe875577c8a Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 12 Jun 2024 15:22:39 +0000 Subject: [PATCH] cleanup: Modernize PubSubRoute code, json parsing --- .../PubSub/Client/Routing/PubSubRouter.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/DataStreamSuite/PubSub/Client/Routing/PubSubRouter.cs b/src/DataStreamSuite/PubSub/Client/Routing/PubSubRouter.cs index 1f0c34bf9..0304c1411 100644 --- a/src/DataStreamSuite/PubSub/Client/Routing/PubSubRouter.cs +++ b/src/DataStreamSuite/PubSub/Client/Routing/PubSubRouter.cs @@ -48,7 +48,8 @@ namespace BCG { throw new ArgumentException($"Failed to find route for tag '{tag}'", nameof(tag)); } Log.Gen.info($"PubSubRouter.get_sub_url_for_tag tag: {tag} route: {route}"); - return RemoteConnectionInfo.parse_url(route.server_address); + ArgumentNullException.ThrowIfNull(route.ServerAddress); + return RemoteConnectionInfo.parse_url(route.ServerAddress); } public RemoteConnectionInfo get_sub_route_for_tag(string tag) { @@ -56,17 +57,18 @@ namespace BCG { throw new ArgumentException($"Failed to find route for tag '{tag}'", nameof(tag)); } Log.Gen.info($"PubSubRouter.get_sub_url_for_tag tag: {tag} route: {route}"); - return RemoteConnectionInfo.parse_url(route.server_address); + ArgumentNullException.ThrowIfNull(route.ServerAddress); + return RemoteConnectionInfo.parse_url(route.ServerAddress); } public List get_all_pubsub_sub_urls() => - _sub_routes.Select(r => r.server_address).ToList(); + _sub_routes.Select(r => r.ServerAddress ?? throw new InvalidOperationException("Route.ServerAddress is null")).ToList(); public List get_all_pubsub_pub_urlss() => - _pub_routes.Select(r => r.server_address).ToList(); + _pub_routes.Select(r => r.ServerAddress ?? throw new InvalidOperationException("Route.ServerAddress is null")).ToList(); - public event PubSubTagURLChangeDelegate onSubURLTagRouteChange; - public event PubSubTagURLChangeDelegate onPubURLTagRouteChange; + public event PubSubTagURLChangeDelegate? onSubURLTagRouteChange; + public event PubSubTagURLChangeDelegate? onPubURLTagRouteChange; #endregion @@ -77,7 +79,5 @@ namespace BCG { aVar = aVar + 2; } } - - } }