Refactor PipeClient to use ServerConnection wrapper and rename Server namespace

Introduce ServerConnection class in PipeClient to encapsulate server process
lifecycle, connection, restart, and cleanup instead of inline Process management.
Pass PipeClient<IPipeServerMethods> explicitly to example methods rather than
relying on a module-level field.

Rename namespace Server to PipeServer in PipeServer project and update
corresponding using directives.

Update error messages in ServerMethods to English.
This commit is contained in:
2026-11-10 13:07:21 +01:00
parent e1acf71c5d
commit beb7086867
3 changed files with 36 additions and 87 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
using PipeShared;
using PipeMethodCalls;
using Server;
using PipeServer;
string pipeName = args.FirstOrDefault(static a => a.StartsWith(PipeConstants.PipeNameArgPrefix, StringComparison.Ordinal))?
var pipeName = args.FirstOrDefault(static a => a.StartsWith(PipeConstants.PipeNameArgPrefix, StringComparison.Ordinal))?
[PipeConstants.PipeNameArgPrefix.Length..] ?? "PipeDemo";
Console.WriteLine($"Server started. Pipe: {pipeName}");
+5 -5
View File
@@ -1,8 +1,8 @@
using PipeShared;
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Numerics;
using PipeShared;
namespace Server;
namespace PipeServer;
public class ServerMethods : IPipeServerMethods
{
@@ -13,7 +13,7 @@ public class ServerMethods : IPipeServerMethods
public double Divide(double a, double b)
{
if (b == 0)
throw new DivideByZeroException("Division durch 0 ist nicht erlaubt.");
throw new DivideByZeroException("Division by 0 not allowed.");
return a / b;
}
@@ -21,7 +21,7 @@ public class ServerMethods : IPipeServerMethods
{
await Task.Delay(50);
if (string.IsNullOrEmpty(text))
throw new ArgumentException("Text darf nicht leer sein.", nameof(text));
throw new ArgumentException("Text must not be empty.", nameof(text));
return $"Echo: {text}";
}