- use switch expression and expression body

pull/26/head
Simon Gockner 6 years ago
parent 037dbfde9c
commit feb4954204
  1. 20
      GBase.Api/Communication/ServerProtocol.cs

@ -38,20 +38,14 @@ namespace GBase.Api.Communication
/// <param name="protocol">The <see cref="ServerProtocol"/></param>
/// <returns>A protocol string for the <see cref="ServerProtocol"/></returns>
/// <exception cref="ArgumentOutOfRangeException">Invalid protocol passed.</exception>
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")
};
/// <summary>
/// Get the <see cref="ServerProtocol"/> for a given <see cref="string"/>

Loading…
Cancel
Save