From 5ba3e8bcaf2420c4aefa80eeed35add54d225274 Mon Sep 17 00:00:00 2001 From: Simon G Date: Sun, 9 Feb 2020 00:33:33 +0100 Subject: [PATCH] - add incompleteArgumentsException --- .../Exceptions/IncompleteArgumentsException.cs | 17 +++++++++++++++++ GBase.Server/ServerProtocol.cs | 10 ++++++++++ 2 files changed, 27 insertions(+) create mode 100644 GBase.Server/Exceptions/IncompleteArgumentsException.cs diff --git a/GBase.Server/Exceptions/IncompleteArgumentsException.cs b/GBase.Server/Exceptions/IncompleteArgumentsException.cs new file mode 100644 index 0000000..ce01e02 --- /dev/null +++ b/GBase.Server/Exceptions/IncompleteArgumentsException.cs @@ -0,0 +1,17 @@ +// Author: Simon Gockner +// Created: 2020-02-09 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using System; + +namespace GBase.Server.Exceptions +{ + public class IncompleteArgumentsException : Exception + { + public IncompleteArgumentsException(string message) + : base(message) + { + + } + } +} \ No newline at end of file diff --git a/GBase.Server/ServerProtocol.cs b/GBase.Server/ServerProtocol.cs index 9c30b26..a272a65 100644 --- a/GBase.Server/ServerProtocol.cs +++ b/GBase.Server/ServerProtocol.cs @@ -29,5 +29,15 @@ namespace GBase.Server throw new ArgumentOutOfRangeException(nameof(protocol), protocol, "Invalid Protocol"); } } + + public static ServerProtocol GetServerProtocolFromString(string @string) + { + if (@string.Equals("http://") || @string.Equals("http")) + return ServerProtocol.Http; + else if (@string.Equals("https://") || @string.Equals("https")) + return ServerProtocol.Https; + else + throw new ArgumentOutOfRangeException(nameof(@string), @string, "Invalid string."); + } } } \ No newline at end of file