From feb4954204ca898aef03cec89f8d7ded8e466d76 Mon Sep 17 00:00:00 2001 From: Simon Gockner Date: Thu, 13 Feb 2020 10:56:01 +0100 Subject: [PATCH] - use switch expression and expression body --- GBase.Api/Communication/ServerProtocol.cs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/GBase.Api/Communication/ServerProtocol.cs b/GBase.Api/Communication/ServerProtocol.cs index 24bd7c4..b395ec4 100644 --- a/GBase.Api/Communication/ServerProtocol.cs +++ b/GBase.Api/Communication/ServerProtocol.cs @@ -38,20 +38,14 @@ namespace GBase.Api.Communication /// The /// A protocol string for the /// Invalid protocol passed. - public static string GetProtocolString(this ServerProtocol protocol) - { - switch (protocol) + public static string GetProtocolString(this ServerProtocol protocol) => + protocol switch { - case ServerProtocol.Http: - return @"http://"; - case ServerProtocol.Https: - return @"https://"; - case ServerProtocol.Tcp: - return @"net.tcp://"; - default: - throw new ArgumentOutOfRangeException(nameof(protocol), protocol, "Invalid Protocol"); - } - } + ServerProtocol.Http => @"http://", + ServerProtocol.Https => @"https://", + ServerProtocol.Tcp => @"net.tcp://", + _ => throw new ArgumentOutOfRangeException(nameof(protocol), protocol, "Invalid Protocol") + }; /// /// Get the for a given