- 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> /// <param name="protocol">The <see cref="ServerProtocol"/></param>
/// <returns>A protocol string for the <see cref="ServerProtocol"/></returns> /// <returns>A protocol string for the <see cref="ServerProtocol"/></returns>
/// <exception cref="ArgumentOutOfRangeException">Invalid protocol passed.</exception> /// <exception cref="ArgumentOutOfRangeException">Invalid protocol passed.</exception>
public static string GetProtocolString(this ServerProtocol protocol) public static string GetProtocolString(this ServerProtocol protocol) =>
{ protocol switch
switch (protocol)
{ {
case ServerProtocol.Http: ServerProtocol.Http => @"http://",
return @"http://"; ServerProtocol.Https => @"https://",
case ServerProtocol.Https: ServerProtocol.Tcp => @"net.tcp://",
return @"https://"; _ => throw new ArgumentOutOfRangeException(nameof(protocol), protocol, "Invalid Protocol")
case ServerProtocol.Tcp: };
return @"net.tcp://";
default:
throw new ArgumentOutOfRangeException(nameof(protocol), protocol, "Invalid Protocol");
}
}
/// <summary> /// <summary>
/// Get the <see cref="ServerProtocol"/> for a given <see cref="string"/> /// Get the <see cref="ServerProtocol"/> for a given <see cref="string"/>

Loading…
Cancel
Save